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 eb5f822
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ pub fn register(target: &Target, verbose: bool) -> Result<()> {
docker_command("run")
.arg("--privileged")
.arg("--rm")
.arg("-i")
.arg("ubuntu:16.04")
.args(&["sh", "-c", cmd])
.run(verbose)
Expand Down Expand Up @@ -161,12 +160,12 @@ pub fn run(target: &Target,
.args(&["-v", &format!("{}:/target:Z", target_dir.display())])
.args(&["-w", "/project"]);

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

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 eb5f822

Please sign in to comment.