Skip to content

Commit

Permalink
Workaround Rust 1.49 breaking macOS processes with a materialized arg…
Browse files Browse the repository at this point in the history
…v0 (#11452)

Works around #11406, which we found is due to rust-lang/rust#80819.

To workaround, we absolutify relative paths when they are argv[0]. We only do this for local execution.
  • Loading branch information
Eric-Arellano authored Jan 13, 2021
1 parent 02434eb commit 24c57c0
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/rust/engine/process_execution/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,19 @@ impl CapturedWorkdir for CommandRunner {
_context: Context,
exclusive_spawn: bool,
) -> Result<BoxStream<'c, Result<ChildOutput, String>>, String> {
let mut command = HermeticCommand::new(&req.argv[0]);
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);
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) => cwd.join(rel_path),
Err(_) => PathBuf::from(&req.argv[0]),
};
let mut command = HermeticCommand::new(argv0);
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,
Expand Down

0 comments on commit 24c57c0

Please sign in to comment.