Skip to content

fix: resolve gbrain CLI path in autopilot wrapper#166

Open
mvanhorn wants to merge 1 commit intogarrytan:masterfrom
mvanhorn:fix/136-autopilot-wrapper-execpath
Open

fix: resolve gbrain CLI path in autopilot wrapper#166
mvanhorn wants to merge 1 commit intogarrytan:masterfrom
mvanhorn:fix/136-autopilot-wrapper-execpath

Conversation

@mvanhorn
Copy link
Copy Markdown

Summary

gbrain autopilot --install generates a wrapper script (~/.gbrain/autopilot-run.sh) that uses process.execPath as the CLI path. On Bun-based installs, process.execPath resolves to the Bun runtime binary (e.g., ~/.bun/bin/bun), not the gbrain CLI. The wrapper then runs exec '/path/to/bun' autopilot which fails with "Script not found" on every launchd/cron invocation.

Changes

Added resolveGbrainPath() in src/commands/autopilot.ts that checks install locations in order:

  1. $BUN_INSTALL/bin/gbrain
  2. ~/.bun/bin/gbrain
  3. /usr/local/bin/gbrain
  4. which gbrain (PATH lookup)
  5. Dev mode fallback: bun /path/to/cli.ts
  6. process.execPath (last resort)

Updated the wrapper template to handle the dev mode two-token command (bun cli.ts) separately from single-path binaries.

Testing

bun test passes (756 pass, 126 skip, 6 pre-existing failures unrelated to this change).

Confirmed process.execPath issue reported by @u8913557 in #136 comment - their workaround validates the root cause.

Fixes #136

This contribution was developed with AI assistance (Claude Code).

process.execPath returns the bun runtime binary, not the gbrain CLI
entry point. The generated autopilot-run.sh wrapper tries to run
`exec '/path/to/bun' autopilot` which fails with "Script not found."

Add resolveGbrainPath() that checks common install locations
($BUN_INSTALL/bin, ~/.bun/bin, /usr/local/bin, PATH) before falling
back to process.execPath. Handles dev mode (bun run src/cli.ts) as
a last resort.

Fixes garrytan#136
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.

autopilot --install generates broken wrapper: execPath resolves to bun runtime, not gbrain CLI

1 participant