From d64cfb87ae002526e8ab04d222c27c3507909174 Mon Sep 17 00:00:00 2001 From: Christopher Serr Date: Tue, 10 Sep 2019 13:09:28 +0200 Subject: [PATCH] Fix cross when stdin is not a TTY 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. --- src/docker.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/docker.rs b/src/docker.rs index 2b1f9e687..4ac273351 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -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) @@ -161,12 +160,15 @@ 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("-i"); + if atty::is(Stream::Stdout) && atty::is(Stream::Stderr) { + docker.arg("-t"); + } } docker - .args(&["-i", &image(toml, target)?]) + .arg(&image(toml, target)?) .args(&["sh", "-c", &format!("PATH=$PATH:/rust/bin {:?}", cmd)]) .run_and_get_status(verbose) }