rust-lang / docker-rust

The official Docker images for Rust
436 stars 88 forks source link

Cargo `install+upgrade` behaviour in 1.48 Docker image? #70

Closed quaos closed 3 years ago

quaos commented 3 years ago

Hi,

I've just found a strange behaviour in rust:1.48-slim docker image when using cargo install inside Dockerfile with cached cargo dir:

FROM rust:1.48-slim

RUN cargo --version \
    && rustup show \
    && cargo install diesel_cli \
    --branch master --git https://github.com/diesel-rs/diesel \
    --no-default-features --features postgres

....
#14 7.471 cargo 1.48.0 (65cbdd2dc 2020-10-14)
#14 7.477 Default host: x86_64-unknown-linux-gnu
#14 7.478 rustup home:  /usr/local/rustup
#14 7.478 
#14 7.572 1.48.0-x86_64-unknown-linux-gnu (overridden by '/root/rust-toolchain')
#14 7.619 rustc 1.48.0 (7eac88abb 2020-11-16)
#14 7.712     Updating git repository `https://github.com/diesel-rs/diesel`
#14 8.377 error: binary `diesel` already exists in destination
#14 8.379 Add --force to overwrite

This is even though the install+upgrade behaviour of Cargo has been stabilized, and running on my local machine do not yield this error when latest diesel is already installed.

# in localhost

$ cargo --version
cargo 1.48.0 (65cbdd2dc 2020-10-14)

$ rustup show
Default host: x86_64-apple-darwin
....
active toolchain
----------------

1.48.0-x86_64-apple-darwin (overridden by '/Users/chakrit_w/Projects/test-rust-caching/rust-toolchain')
rustc 1.48.0 (7eac88abb 2020-11-16)

$ cargo install diesel_cli \
    --branch master --git https://github.com/diesel-rs/diesel \
    --no-default-features --features postgres

    Updating git repository `https://github.com/diesel-rs/diesel`
     Ignored package `diesel_cli v1.4.0 (https://github.com/diesel-rs/diesel?branch=master#493541dd)` is already installed, use --force to override

Please help investigate this - Thanks!

sfackler commented 3 years ago

This sounds like something you should file on Cargo - there's nothing special going on with the Docker image generation itself as far as I know.