diff --git a/nativelink-worker/src/running_actions_manager.rs b/nativelink-worker/src/running_actions_manager.rs index 993be3dab..398e1da46 100644 --- a/nativelink-worker/src/running_actions_manager.rs +++ b/nativelink-worker/src/running_actions_manager.rs @@ -929,7 +929,24 @@ impl RunningActionImpl { // De-bloat the `debug` level by using the `trace` // level more effectively and adjust this. info!(?args, "Executing command",); - let mut command_builder = process::Command::new(args[0]); + + // If the program contains a slash, we treat it as a path and resolve it relative to the work directory. + let program = if Path::new(&args[0]).components().count() > 1 { + PathBuf::from(&self.work_directory) + .join(&command_proto.working_directory) + .join(&args[0]) + .canonicalize() + .err_tip(|| { + format!( + "Could not canonicalize path for command root {}.", + args[0].to_string_lossy() + ) + })? + } else { + PathBuf::from(&args[0]) + }; + + let mut command_builder = process::Command::new(program); command_builder .args(&args[1..]) .kill_on_drop(true)