From 8b465feb5b661dbd8773d94079ca5715c07e9b3b Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Tue, 12 Jan 2021 15:01:21 -0700 Subject: [PATCH 1/2] Workaround Rust 1.49 breaking macOS processes with a materialized argv0 # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels] --- src/rust/engine/process_execution/src/local.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/rust/engine/process_execution/src/local.rs b/src/rust/engine/process_execution/src/local.rs index 8927de271d0..b575366cbd0 100644 --- a/src/rust/engine/process_execution/src/local.rs +++ b/src/rust/engine/process_execution/src/local.rs @@ -288,7 +288,19 @@ impl CapturedWorkdir for CommandRunner { _context: Context, exclusive_spawn: bool, ) -> Result>, String> { - let mut command = HermeticCommand::new(&req.argv[0]); + // TODO(#11406): Go back to using relative paths, rather than absolutifying them, once Rust + // fixes https://github.com/rust-lang/rust/issues/80819 for macOS. + let argv0 = match RelativePath::new(&req.argv[0]) { + Ok(rel_path) => { + if let Some(ref working_directory) = req.working_directory { + workdir_path.join(working_directory).join(rel_path) + } else { + workdir_path.join(rel_path) + } + } + Err(_) => PathBuf::from(&req.argv[0]), + }; + let mut command = HermeticCommand::new(argv0); command .args(&req.argv[1..]) .current_dir(if let Some(ref working_directory) = req.working_directory { From aa50cf924eed5c450a9d22253f6e5e00eb918dc8 Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Tue, 12 Jan 2021 18:06:33 -0700 Subject: [PATCH 2/2] Review feedback # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels] --- .../engine/process_execution/src/local.rs | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/rust/engine/process_execution/src/local.rs b/src/rust/engine/process_execution/src/local.rs index b575366cbd0..0d234908d6b 100644 --- a/src/rust/engine/process_execution/src/local.rs +++ b/src/rust/engine/process_execution/src/local.rs @@ -288,27 +288,19 @@ impl CapturedWorkdir for CommandRunner { _context: Context, exclusive_spawn: bool, ) -> Result>, String> { + let cwd = if let Some(ref working_directory) = req.working_directory { + workdir_path.join(working_directory) + } else { + workdir_path.to_owned() + }; // TODO(#11406): Go back to using relative paths, rather than absolutifying them, once Rust // fixes https://github.com/rust-lang/rust/issues/80819 for macOS. let argv0 = match RelativePath::new(&req.argv[0]) { - Ok(rel_path) => { - if let Some(ref working_directory) = req.working_directory { - workdir_path.join(working_directory).join(rel_path) - } else { - workdir_path.join(rel_path) - } - } + Ok(rel_path) => cwd.join(rel_path), Err(_) => PathBuf::from(&req.argv[0]), }; let mut command = HermeticCommand::new(argv0); - command - .args(&req.argv[1..]) - .current_dir(if let Some(ref working_directory) = req.working_directory { - workdir_path.join(working_directory) - } else { - workdir_path.to_owned() - }) - .envs(&req.env); + command.args(&req.argv[1..]).current_dir(cwd).envs(&req.env); // See the documentation of the `CapturedWorkdir::run_in_workdir` method, but `exclusive_spawn` // indicates the binary we're spawning was written out by the current thread, and, as such,