From 549e0349d7aaf0aad04bca182617d50cb5d7d8a6 Mon Sep 17 00:00:00 2001 From: Timmy Date: Tue, 14 Jul 2026 18:42:55 +0100 Subject: [PATCH] Fix rebuild_and_restart in Docker project containers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CARGO_MANIFEST_DIR is baked at image build time as /app/server, but project containers (Dockerfile.base) don't copy /app — the source is bind-mounted at /workspace instead. Fall back to project_root when the compile-time path doesn't exist. Co-Authored-By: Claude Opus 4.6 --- server/src/rebuild.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/server/src/rebuild.rs b/server/src/rebuild.rs index e8d96828..f4805cea 100644 --- a/server/src/rebuild.rs +++ b/server/src/rebuild.rs @@ -107,11 +107,25 @@ pub async fn rebuild_and_restart( // 2. Find the workspace root (parent of the server binary's source). // CARGO_MANIFEST_DIR at compile time points to the `server/` crate; - // the workspace root is its parent. - let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")); - let workspace_root = manifest_dir + // the workspace root is its parent. When running inside Docker the + // compile-time path (/app) no longer exists — the source is bind-mounted + // at the project_root instead, so fall back to that. + let compile_time_root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) .parent() - .ok_or_else(|| "Cannot determine workspace root from CARGO_MANIFEST_DIR".to_string())?; + .filter(|p| p.join("Cargo.toml").exists()); + let workspace_root = match compile_time_root { + Some(p) => p.to_path_buf(), + None => { + if project_root.join("Cargo.toml").exists() { + project_root.to_path_buf() + } else { + return Err( + "Cannot determine workspace root: neither CARGO_MANIFEST_DIR nor project_root contain Cargo.toml".to_string(), + ); + } + } + }; + let workspace_root = workspace_root.as_path(); slog!( "[rebuild] Building server from workspace root: {}",