From cd095f9a995ac423a0c63c2318aa9efebc96ab33 Mon Sep 17 00:00:00 2001 From: Timmy Date: Sat, 21 Mar 2026 20:42:38 +0000 Subject: [PATCH] Fix rebuild_and_restart in Docker by using cargo output path Use the known cargo build output path instead of current_exe() when re-execing after a rebuild. In Docker, the running binary lives at /usr/local/bin/storkit (read-only) while cargo writes the new binary to /app/target/release/storkit (a writable volume), so current_exe() would just restart the old binary. Co-Authored-By: Claude Opus 4.6 (1M context) --- server/src/rebuild.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/server/src/rebuild.rs b/server/src/rebuild.rs index 942999b..374ae0d 100644 --- a/server/src/rebuild.rs +++ b/server/src/rebuild.rs @@ -70,9 +70,15 @@ pub async fn rebuild_and_restart(agents: &AgentPool, project_root: &Path) -> Res slog!("[rebuild] Build succeeded, re-execing with new binary"); // 4. Re-exec with the new binary. - // Collect current argv so we preserve any CLI arguments (e.g. project path). - let current_exe = - std::env::current_exe().map_err(|e| format!("Cannot determine current executable: {e}"))?; + // Use the cargo output path rather than current_exe() so that rebuilds + // inside Docker work correctly — the running binary may be installed at + // /usr/local/bin/storkit (read-only) while cargo writes the new binary + // to /app/target/release/storkit (a writable volume). + let new_exe = if cfg!(debug_assertions) { + workspace_root.join("target/debug/storkit") + } else { + workspace_root.join("target/release/storkit") + }; let args: Vec = std::env::args().collect(); // Remove the port file before re-exec so the new process can write its own. @@ -89,7 +95,7 @@ pub async fn rebuild_and_restart(agents: &AgentPool, project_root: &Path) -> Res // Use exec() to replace the current process. // This never returns on success. use std::os::unix::process::CommandExt; - let err = std::process::Command::new(¤t_exe) + let err = std::process::Command::new(&new_exe) .args(&args[1..]) .exec();