Skip to content

Commit

Permalink
Fix cross when stdin is not a TTY
Browse files Browse the repository at this point in the history
When stdin is not a TTY, cross fails because it still passes `-i` to
`docker run`, which makes Docker fail like so:
```
the input device is not a TTY
```
Apparently GitHub Actions doesn't have a TTY as stdin, so this is the
fix to make cross work with GitHub Actions.
  • Loading branch information
CryZe committed Sep 10, 2019
1 parent fc6d350 commit 8003113
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 @@ -59,10 +59,10 @@ pub fn register(target: &Target, verbose: bool) -> Result<()> {
"apt-get update && apt-get install --no-install-recommends -y \
binfmt-support qemu-user-static"
};

docker_command("run")
.arg("--privileged")
.arg("--rm")
.arg("-i")
.arg("ubuntu:16.04")
.args(&["sh", "-c", cmd])
.run(verbose)
Expand Down Expand Up @@ -163,10 +163,13 @@ pub fn run(target: &Target,

if atty::is(Stream::Stdout) && atty::is(Stream::Stderr) {
docker.arg("-t");
if atty::is(Stream::Stdin) {
docker.arg("-i");
}
}

docker
.args(&["-i", &image(toml, target)?])
.arg(&image(toml, target)?)
.args(&["sh", "-c", &format!("PATH=$PATH:/rust/bin {:?}", cmd)])
.run_and_get_status(verbose)
}
Expand Down

0 comments on commit 8003113

Please sign in to comment.