Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround Rust 1.49 breaking macOS processes with a materialized argv0 #11452

Merged
merged 3 commits into from
Jan 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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