Skip to content

Commit c31bd9d

Browse files
committed
Auto merge of #7877 - joshtriplett:env-order, r=ehuss
Keep environment variables in a BTreeMap to preserve sort order This prevents verbose output from varying between runs due to HashMap (non-)ordering.
2 parents 3c53211 + e84a4ed commit c31bd9d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/cargo/util/process_builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::util::{process_error, read2, CargoResult, CargoResultExt};
22
use anyhow::bail;
33
use jobserver::Client;
44
use shell_escape::escape;
5-
use std::collections::HashMap;
5+
use std::collections::BTreeMap;
66
use std::env;
77
use std::ffi::{OsStr, OsString};
88
use std::fmt;
@@ -17,7 +17,7 @@ pub struct ProcessBuilder {
1717
/// A list of arguments to pass to the program.
1818
args: Vec<OsString>,
1919
/// Any environment variables that should be set for the program.
20-
env: HashMap<String, Option<OsString>>,
20+
env: BTreeMap<String, Option<OsString>>,
2121
/// The directory to run the program from.
2222
cwd: Option<OsString>,
2323
/// The `make` jobserver. See the [jobserver crate][jobserver_docs] for
@@ -128,7 +128,7 @@ impl ProcessBuilder {
128128

129129
/// Gets all environment variables explicitly set or unset for the process (not inherited
130130
/// vars).
131-
pub fn get_envs(&self) -> &HashMap<String, Option<OsString>> {
131+
pub fn get_envs(&self) -> &BTreeMap<String, Option<OsString>> {
132132
&self.env
133133
}
134134

@@ -334,7 +334,7 @@ pub fn process<T: AsRef<OsStr>>(cmd: T) -> ProcessBuilder {
334334
program: cmd.as_ref().to_os_string(),
335335
args: Vec::new(),
336336
cwd: None,
337-
env: HashMap::new(),
337+
env: BTreeMap::new(),
338338
jobserver: None,
339339
display_env_vars: false,
340340
}

0 commit comments

Comments
 (0)