Skip to content

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

Merged
DOsinga merged 1 commit into
mainfrom
goose-calls-goose
May 18, 2026
Merged

fix: use current_exe() instead of PATH lookup when spawning goose#9236
DOsinga merged 1 commit into
mainfrom
goose-calls-goose

Conversation

@matt2e

@matt2e matt2e commented May 14, 2026

Copy link
Copy Markdown
Collaborator

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>

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

Copy link
Copy Markdown

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.

@DOsinga DOsinga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not sure we should be using goose project anymore, but fine!

@DOsinga
DOsinga added this pull request to the merge queue May 18, 2026
Merged via the queue into main with commit 688b6d7 May 18, 2026
22 checks passed
@DOsinga
DOsinga deleted the goose-calls-goose branch May 18, 2026 14:29
michaelneale added a commit that referenced this pull request May 19, 2026
* 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
shafqatevo pushed a commit to shafqatevo/goose that referenced this pull request Aug 7, 2026
…if-goose#9236)

Signed-off-by: Matt Toohey <contact@matttoohey.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants