From ba0eb7e6c88b0672a0eb3348e9a1ac0ee6b7fe34 Mon Sep 17 00:00:00 2001 From: chr1syy Date: Mon, 1 Jun 2026 12:44:36 +0200 Subject: [PATCH] fix(installer): set PATH on systemd unit and launchd plist Service-managed maestro-relay processes inherit systemd's minimal PATH, so they resolve `maestro-cli` to the older /usr/local/bin shim (which calls bare `node` and fails with exit 127 when node isn't on PATH) instead of the newer ~/.local/bin Electron-backed shim that has no node-on-PATH dependency. Bake a sane PATH into both service templates with $HOME/.local/bin and the node bin directory ahead of system paths, so the user-mode Maestro CLI shim is found first and the legacy shim's bare `node` call still resolves as a fallback. install.sh now derives @HOME@ and @NODE_DIR@ from $HOME and dirname \$(command -v node) and passes them through to both templates. Co-Authored-By: Claude Opus 4.7 (1M context) --- install.sh | 12 ++++++++++-- templates/maestro-relay.service | 1 + templates/sh.maestro.relay.plist | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 17c559e..6817aef 100755 --- a/install.sh +++ b/install.sh @@ -534,10 +534,14 @@ install_service_linux() { mkdir -p "$unit_dir" local template="$INSTALL_DIR/templates/maestro-relay.service" [ -f "$template" ] || { warn "Service template missing at $template"; return; } + local node_bin; node_bin="$(command -v node)" + local node_dir; node_dir="$(dirname "$node_bin")" sed \ -e "s|@INSTALL_DIR@|$INSTALL_DIR|g" \ -e "s|@CONFIG_DIR@|$CONFIG_DIR|g" \ - -e "s|@NODE_BIN@|$(command -v node)|g" \ + -e "s|@NODE_BIN@|$node_bin|g" \ + -e "s|@NODE_DIR@|$node_dir|g" \ + -e "s|@HOME@|$HOME|g" \ "$template" > "$unit_dir/maestro-relay.service" # Disable+remove a legacy maestro-discord unit if present so we don't leave # two competing user services running on upgrade. @@ -563,10 +567,14 @@ install_service_macos() { mkdir -p "$INSTALL_DIR/logs" local template="$INSTALL_DIR/templates/sh.maestro.relay.plist" [ -f "$template" ] || { warn "Plist template missing at $template"; return; } + local node_bin; node_bin="$(command -v node)" + local node_dir; node_dir="$(dirname "$node_bin")" sed \ -e "s|@INSTALL_DIR@|$INSTALL_DIR|g" \ -e "s|@CONFIG_DIR@|$CONFIG_DIR|g" \ - -e "s|@NODE_BIN@|$(command -v node)|g" \ + -e "s|@NODE_BIN@|$node_bin|g" \ + -e "s|@NODE_DIR@|$node_dir|g" \ + -e "s|@HOME@|$HOME|g" \ "$template" > "$plist_dir/sh.maestro.relay.plist" # Unload+remove a legacy launchd plist if present. if [ -f "$plist_dir/sh.maestro.discord.plist" ]; then diff --git a/templates/maestro-relay.service b/templates/maestro-relay.service index d503a62..77bda90 100644 --- a/templates/maestro-relay.service +++ b/templates/maestro-relay.service @@ -9,6 +9,7 @@ StartLimitBurst=5 Type=simple WorkingDirectory=@INSTALL_DIR@ EnvironmentFile=@CONFIG_DIR@/.env +Environment=PATH=@HOME@/.local/bin:@NODE_DIR@:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin ExecStart=@NODE_BIN@ @INSTALL_DIR@/dist/index.js Restart=on-failure RestartSec=5 diff --git a/templates/sh.maestro.relay.plist b/templates/sh.maestro.relay.plist index f436629..a8f1f3a 100644 --- a/templates/sh.maestro.relay.plist +++ b/templates/sh.maestro.relay.plist @@ -10,7 +10,7 @@ /bin/bash -c - set -a; . "@CONFIG_DIR@/.env"; set +a; export PATH="/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin${PATH:+:$PATH}"; exec "@NODE_BIN@" "@INSTALL_DIR@/dist/index.js" + set -a; . "@CONFIG_DIR@/.env"; set +a; export PATH="@HOME@/.local/bin:@NODE_DIR@:/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin${PATH:+:$PATH}"; exec "@NODE_BIN@" "@INSTALL_DIR@/dist/index.js" RunAtLoad