fix: resolve gbrain CLI path in autopilot wrapper#166
Open
mvanhorn wants to merge 1 commit intogarrytan:masterfrom
Open
fix: resolve gbrain CLI path in autopilot wrapper#166mvanhorn wants to merge 1 commit intogarrytan:masterfrom
mvanhorn wants to merge 1 commit intogarrytan:masterfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gbrain autopilot --installgenerates a wrapper script (~/.gbrain/autopilot-run.sh) that usesprocess.execPathas the CLI path. On Bun-based installs,process.execPathresolves to the Bun runtime binary (e.g.,~/.bun/bin/bun), not thegbrainCLI. The wrapper then runsexec '/path/to/bun' autopilotwhich fails with "Script not found" on every launchd/cron invocation.Changes
Added
resolveGbrainPath()insrc/commands/autopilot.tsthat checks install locations in order:$BUN_INSTALL/bin/gbrain~/.bun/bin/gbrain/usr/local/bin/gbrainwhich gbrain(PATH lookup)bun /path/to/cli.tsprocess.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 testpasses (756 pass, 126 skip, 6 pre-existing failures unrelated to this change).Confirmed
process.execPathissue reported by @u8913557 in #136 comment - their workaround validates the root cause.Fixes #136
This contribution was developed with AI assistance (Claude Code).