fix: use current_exe() instead of PATH lookup when spawning goose#9236
fix: use current_exe() instead of PATH lookup when spawning goose#9236matt2e wants to merge 1 commit into
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.
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