Skip to content

scaffold: cli apps find a user-installed CLI outside the daemon's PATH - #128

Open
TeoSlayer wants to merge 1 commit into
mainfrom
fix/cli-user-bin-dirs
Open

TeoSlayer wants to merge 1 commit into
mainfrom
fix/cli-user-bin-dirs

Conversation

@TeoSlayer

Copy link
Copy Markdown
Contributor

Summary

Apps inherit the daemon's environment, and the daemon runs under launchd or systemd with a minimal PATH. On this Mac the running daemon has PATH=/usr/bin:/bin:/usr/sbin:/sbin. Every directory on it is system-protected, so a user can't even symlink a tool there.

A cli app whose backend.command is a bare name (no assets) therefore can't find a CLI the user installed per-user, for example in ~/.local/bin (DoorDash's dd-cli installer, pipx) or via Homebrew. The call fails with executable file not found in $PATH, although the same command works in the user's shell.

The generated adapter now does this when the bare command isn't on PATH: it looks in ~/.local/bin, /opt/homebrew/bin, /usr/local/bin and ~/bin (first executable wins) before giving up. An absolute path or a staged asset is used exactly as before. If nothing is found, the error still names the bare command.

Tests

  • New TestCLIAdapterFindsCommandInUserBinDir: it builds a real adapter, starts it with the launchd PATH and a HOME whose ~/.local/bin holds the tool, and calls it over IPC. It fails without this change with exec: "userbintool": executable file not found in $PATH.
  • go build ./..., go vet ./... and go test ./... pass. gofmt is clean.

Needed by the DoorDash CLI app (draft, not listed), which fronts the user's own dd-cli from ~/.local/bin.

🤖 Generated with Claude Code

The daemon runs under launchd or systemd with a minimal PATH
(/usr/bin:/bin:/usr/sbin:/sbin on macOS), and apps inherit it. A CLI the
user installed in ~/.local/bin (DoorDash's dd-cli, pipx) or with
Homebrew runs from their shell but failed in the app with "executable
file not found in $PATH".

When the base command is a bare name PATH cannot resolve, the generated
adapter now looks in ~/.local/bin, /opt/homebrew/bin, /usr/local/bin
and ~/bin before giving up. Paths and staged assets are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant