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) <noreply@anthropic.com>
This commit is contained in:
Timmy
2026-03-21 20:42:38 +00:00
parent fe0f560b58
commit cd095f9a99

View File

@@ -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<String> = 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(&current_exe)
let err = std::process::Command::new(&new_exe)
.args(&args[1..])
.exec();