From f1178a0874b8d15db99b1575de19a69950e2f398 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Fri, 15 May 2026 09:43:19 +1000 Subject: [PATCH] fix: use current_exe() instead of PATH lookup when spawning goose 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) Signed-off-by: Matt Toohey --- crates/goose-cli/src/commands/project.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/goose-cli/src/commands/project.rs b/crates/goose-cli/src/commands/project.rs index 7937e5b04f0a..c0a55dedac5d 100644 --- a/crates/goose-cli/src/commands/project.rs +++ b/crates/goose-cli/src/commands/project.rs @@ -16,13 +16,16 @@ fn format_date(date: DateTime) -> String { /// /// 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()) + .unwrap_or_else(|_| "goose".to_string()); let tracker = ProjectTracker::load()?; let mut projects = tracker.list_projects(); if projects.is_empty() { // If no projects exist, just start a new one in the current directory println!("No previous projects found. Starting a new session in the current directory."); - let mut command = std::process::Command::new("goose"); + let mut command = std::process::Command::new(&goose_bin); command.arg("session"); let status = command.status()?; @@ -102,7 +105,7 @@ pub fn handle_project_default() -> Result<()> { std::env::set_current_dir(project_dir)?; // Build the command to run goose - let mut command = std::process::Command::new("goose"); + let mut command = std::process::Command::new(&goose_bin); command.arg("session"); if let Some(id) = session_id { @@ -127,7 +130,7 @@ pub fn handle_project_default() -> Result<()> { std::env::set_current_dir(project_dir)?; // Build the command to run goose with a fresh session - let mut command = std::process::Command::new("goose"); + let mut command = std::process::Command::new(&goose_bin); command.arg("session"); // Execute the command @@ -141,7 +144,7 @@ pub fn handle_project_default() -> Result<()> { let _ = outro("Starting a new session in the current directory"); // Build the command to run goose - let mut command = std::process::Command::new("goose"); + let mut command = std::process::Command::new(&goose_bin); command.arg("session"); // Execute the command @@ -163,6 +166,9 @@ pub fn handle_project_default() -> Result<()> { /// /// Shows a list of projects and lets the user select one to resume pub fn handle_projects_interactive() -> Result<()> { + let goose_bin = std::env::current_exe() + .map(|p| p.to_string_lossy().into_owned()) + .unwrap_or_else(|_| "goose".to_string()); let tracker = ProjectTracker::load()?; let mut projects = tracker.list_projects(); @@ -281,7 +287,7 @@ pub fn handle_projects_interactive() -> Result<()> { }; // Build the command to run goose - let mut command = std::process::Command::new("goose"); + let mut command = std::process::Command::new(&goose_bin); command.arg("session"); if resume_session {