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();