fix: use current_exe() instead of PATH lookup when spawning goose - #9236
Conversation
project.rs spawned child goose processes via `Command::new("goose")`,
which does a PATH lookup and can resolve a different binary version
than the one currently running. Use `std::env::current_exe()` with a
fallback, matching the pattern already used in term.rs.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f1178a0874
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| /// Offers options to resume the most recently accessed project | ||
| pub fn handle_project_default() -> Result<()> { | ||
| let goose_bin = std::env::current_exe() | ||
| .map(|p| p.to_string_lossy().into_owned()) |
There was a problem hiding this comment.
Preserve non-UTF-8 executable paths
When goose is launched from a path that contains non-UTF-8 bytes, current_exe() still returns a valid PathBuf, but to_string_lossy() replaces those bytes with U+FFFD; the later Command::new(&goose_bin) then tries to execute a different path and goose project cannot start the session. Command::new accepts the PathBuf/OsStr directly, so keeping the path in its native representation avoids breaking these installs; the same lossy value is used for all project spawns.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This branch is consistent with how this is done else where in the code base:
term.rs:
let goose_bin = std::env::current_exe()
.map(|p| p.to_string_lossy().into_owned())
.unwrap_or_else(|_| "goose".to_string());I'm ok with solving this issue as well, but didn't want to change more than just the issue I found.
DOsinga
left a comment
There was a problem hiding this comment.
not sure we should be using goose project anymore, but fine!
* origin/main: (160 commits) Add Linux musl CLI builds (#9240) feat(acp): paginate session list (#9199) docs: reorganize (#9310) Structured per-provider config block, non-destructive provider switching (#8977) feat(cli): add `goose review` local code review command (#9114) feat(tui): diff viewer (#9260) fix(otel): emit trace_output as span attribute instead of event (#9255) docs: add guide for connecting goose Desktop to a remote goosed server (#9275) fix(config): check file fallback when keyring has no entry (#9279) fix(desktop): ScheduleModal error message styling (#9278) fix(ui): align sidebar hamburger in macOS fullscreen (#9257) Add documentation for new provider SaladCloud AI Gateway (#9253) fix: use current_exe() instead of PATH lookup when spawning goose (#9236) fix(extension_manager): set TCP_USER_TIMEOUT on streamable HTTP clients (#9207) fix: activate custom provider after adding via configure (#9213) Flush OTLP traces reliably on exit with configurable timeout (#9228) fix: reduce excessive MISSING_TRANSLATION warnings for fallback locales (#9294) feat(acp): pass session cwd param to acp providers (#9229) fix(desktop): eliminate cross-window deep link contamination (#9273) fix: improve Telegram gateway error reporting and connection reliability (#9223) ... Signed-off-by: Michael Neale <michael.neale@gmail.com> # Conflicts: # crates/goose/src/agents/agent.rs # crates/goose/tests/agent.rs
…if-goose#9236) Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
goose project), it now usesstd::env::current_exe()to locate the running binary instead of relying on a"goose"PATH lookup. This mirrors other code paths in goose.goosebinary (or none at all) could be invoked if the current executable isn't onPATHor a different version shadows it.Test plan
cargo buildsucceedsgoose projectand confirm it spawns a session using the same binary🤖 Generated with Claude Code