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: {}",