Skip to content

fix: use current_exe() instead of PATH lookup when spawning goose#9236

Open
matt2e wants to merge 1 commit into
mainfrom
goose-calls-goose
Open

fix: use current_exe() instead of PATH lookup when spawning goose#9236
matt2e wants to merge 1 commit into
mainfrom
goose-calls-goose

Conversation

@matt2e
Copy link
Copy Markdown
Collaborator

@matt2e matt2e commented May 14, 2026

Summary

  • When goose spawns a new session (e.g. from goose project), it now uses std::env::current_exe() to locate the running binary instead of relying on a "goose" PATH lookup. This mirrors other code paths in goose.
  • This fixes issues where the wrong goose binary (or none at all) could be invoked if the current executable isn't on PATH or a different version shadows it.

Test plan

  • Verified cargo build succeeds
  • Run goose project and confirm it spawns a session using the same binary

🤖 Generated with Claude Code

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>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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())
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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