diff options
| author | bors <bors@rust-lang.org> | 2014-10-01 15:32:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-10-01 15:32:30 +0000 |
| commit | 49fcb27df63b845c42d4883c47d2cfc512edeb78 (patch) | |
| tree | 56a257e77052d1258959c14723ba1f160e1f7f76 /src/libstd | |
| parent | 00ebebb25883a5f0c0af73c17152b6bfefdc3c74 (diff) | |
| parent | 5f4c2800fcf0556b351857867e5b527af77149ee (diff) | |
| download | rust-49fcb27df63b845c42d4883c47d2cfc512edeb78.tar.gz rust-49fcb27df63b845c42d4883c47d2cfc512edeb78.zip | |
auto merge of #17667 : wizeman/rust/fix-override-env, r=alexcrichton
In some build environments (such as chrooted Nix builds), `env` can only be found in the explicitly-provided PATH, not in default places such as /bin or /usr/bin. So we need to pass-through PATH when spawning the `env` sub-process. Fixes #17617
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/process.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index f97e9f4647b..56bdbe4a979 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -956,7 +956,22 @@ mod tests { }) iotest!(fn test_override_env() { - let new_env = vec![("RUN_TEST_NEW_ENV", "123")]; + use os; + let mut new_env = vec![("RUN_TEST_NEW_ENV", "123")]; + + // In some build environments (such as chrooted Nix builds), `env` can + // only be found in the explicitly-provided PATH env variable, not in + // default places such as /bin or /usr/bin. So we need to pass through + // PATH to our sub-process. + let path_val: String; + match os::getenv("PATH") { + None => {} + Some(val) => { + path_val = val; + new_env.push(("PATH", path_val.as_slice())) + } + } + let prog = env_cmd().env_set_all(new_env.as_slice()).spawn().unwrap(); let result = prog.wait_with_output().unwrap(); let output = String::from_utf8_lossy(result.output.as_slice()).into_string(); |
