Skip to content

Commit

Permalink
Merge #505
Browse files Browse the repository at this point in the history
505: Make the `USER` variable to `docker` optional r=reitermarkus a=eZanmoto

Populating this variable fails under Linux if the local user doesn't have a username. This may happen when using Docker and mapping a user ID from the host into a container, such as when using `--user=$(id -u):$(id -g)`. I suggest making the `USER` environment variable passed to `docker` optional, which allows `cross` to work in the given scenario.

Co-authored-by: Sean Kelleher <ezanmoto@gmail.com>
  • Loading branch information
bors[bot] and eZanmoto committed Aug 29, 2021
2 parents 09c0d9c + e0a2ae9 commit f37d159
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,11 @@ pub fn run(
docker
.args(&["-e", "XARGO_HOME=/xargo"])
.args(&["-e", "CARGO_HOME=/cargo"])
.args(&["-e", "CARGO_TARGET_DIR=/target"])
.args(&["-e", &format!("USER={}", id::username().unwrap().unwrap())]);
.args(&["-e", "CARGO_TARGET_DIR=/target"]);

if let Some(username) = id::username().unwrap() {
docker.args(&["-e", &format!("USER={}", username)]);
}

if let Ok(value) = env::var("QEMU_STRACE") {
docker.args(&["-e", &format!("QEMU_STRACE={}", value)]);
Expand Down

0 comments on commit f37d159

Please sign in to comment.