cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.59k stars 366 forks source link

Remove the --progress flag #1419

Closed chanderlud closed 8 months ago

chanderlud commented 8 months ago

Newer versions of Docker no longer support the --progress flag on the docker build command. This causes Cross to fail when using versions of Docker such as 23 and 24.

For example:

docker --version
Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1
cross build --target aarch64-unknown-linux-gnu
info: downloading component 'rust-std' for 'aarch64-unknown-linux-gnu'
info: installing component 'rust-std' for 'aarch64-unknown-linux-gnu'
unknown flag: --progress
See 'docker --help'.

I have removed the progress code from cross in this pull request, this error no longer occurs.

Emilgardis commented 8 months ago

This pr solves a problem which doesn't exist, the situation here is unfortunate though.

We don't call docker build, we call docker buildx build , which absolutely does support --progress. The issue here is how docker handles error reporting. See https://github.com/cross-rs/cross/issues/1055

You should be getting an error message in the cross output suggesting how to fix this, which is to check that buildx/buildkit is available or to set CROSS_CONTAINER_ENGINE_NO_BUILDKIT=1

chanderlud commented 8 months ago

Yup, installing buildx got rid of the progress error. Do you think it would be reasonable for Cross to check if buildx is installed before trying to use it? That way a more helpful error message could be delivered to the user.

Emilgardis commented 8 months ago

If you can find a good way to detect buildx, I'd be happy to include a check like that!

chanderlud commented 8 months ago

It looks like the docker buildx version command is a good candidate for testing installation. I wrote this function to test for buildx being installed, but I am not sure what the best place to call it from would be.

fn is_buildx() -> bool {
    let mut cmd = Command::new("docker");
    cmd.args(["buildx", "version"])
        .output()
        // if buildx is present, it will print the version and exit 0
        // if buildx is not present, it will print a warning and exit 1
        .map_or(false, |out| out.status.success())
}