rustup icon indicating copy to clipboard operation
rustup copied to clipboard

`rustup show` downloads components when `rust-toolchain` file is present

Open Veetaha opened this issue 2 years ago • 1 comments

Problem

To our surprise running rustup show when the repository contains rust-toolchain file causes it to download some components. After that when installing the toolchain rustfmt appears to be absent, which originally failed our CI.

Here is the high-level view of the CI run in our private repo with detailed logs under the spoiler bellow

image
Detailed logs from CI
##[group]Run rustup show
rustup show
shell: /usr/bin/bash -e {0}
env:
  AWS_ACCESS_KEY_ID: ***
  AWS_DEFAULT_REGION: us-east-2
  AWS_SECRET_ACCESS_KEY: ***
  CARGO_INCREMENTAL: 0
  CARGO_NET_RETRY: 50
  RUSTDOCFLAGS: -Aunstable-name-collisions --deny warnings
  RUSTFLAGS: -Aunstable-name-collisions --deny warnings -Cdebuginfo=0
  RUSTUP_MAX_RETRIES: 10
  RUST_BACKTRACE: full
  TF_IN_AUTOMATION: 1
  CLOUDSMITH_API_KEY: ***
##[endgroup]
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/runner/.rustup

info: syncing channel updates for '1.60.0-x86_64-unknown-linux-gnu'
info: latest update on 2022-04-07, rust version 1.60.0 (7737e0b5c 2022-04-04)
info: downloading component 'cargo'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: installing component 'cargo'
info: installing component 'rust-std'
info: installing component 'rustc'
1.60.0-x86_64-unknown-linux-gnu (overridden by '/home/runner/work/elastio/elastio/rust-toolchain')
rustc 1.60.0 (7737e0b5c 2022-04-04)
##[group]Run rustup -V
rustup -V
shell: /usr/bin/bash -e {0}
env:
  AWS_ACCESS_KEY_ID: ***
  AWS_DEFAULT_REGION: us-east-2
  AWS_SECRET_ACCESS_KEY: ***
  CARGO_INCREMENTAL: 0
  CARGO_NET_RETRY: 50
  RUSTDOCFLAGS: -Aunstable-name-collisions --deny warnings
  RUSTFLAGS: -Aunstable-name-collisions --deny warnings -Cdebuginfo=0
  RUSTUP_MAX_RETRIES: 10
  RUST_BACKTRACE: full
  TF_IN_AUTOMATION: 1
  CLOUDSMITH_API_KEY: ***
##[endgroup]
info: This is the version for the rustup toolchain manager, not the rustc compiler.
rustup 1.24.3 (ce5817a94 2021-05-31)
info: The currently active `rustc` version is `rustc 1.60.0 (7737e0b5c 2022-04-04)`
##[group]Run rustup -V
rustup -V
shell: /usr/bin/bash -e {0}
env:
  AWS_ACCESS_KEY_ID: ***
  AWS_DEFAULT_REGION: us-east-2
  AWS_SECRET_ACCESS_KEY: ***
  CARGO_INCREMENTAL: 0
  CARGO_NET_RETRY: 50
  RUSTDOCFLAGS: -Aunstable-name-collisions --deny warnings
  RUSTFLAGS: -Aunstable-name-collisions --deny warnings -Cdebuginfo=0
  RUSTUP_MAX_RETRIES: 10
  RUST_BACKTRACE: full
  TF_IN_AUTOMATION: 1
  CLOUDSMITH_API_KEY: ***
##[endgroup]
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.60.0 (7737e0b5c 2022-04-04)`
##[group]Run rustup set profile default
rustup set profile default
shell: /usr/bin/bash -e {0}
env:
  AWS_ACCESS_KEY_ID: ***
  AWS_DEFAULT_REGION: us-east-2
  AWS_SECRET_ACCESS_KEY: ***
  CARGO_INCREMENTAL: 0
  CARGO_NET_RETRY: 50
  RUSTDOCFLAGS: -Aunstable-name-collisions --deny warnings
  RUSTFLAGS: -Aunstable-name-collisions --deny warnings -Cdebuginfo=0
  RUSTUP_MAX_RETRIES: 10
  RUST_BACKTRACE: full
  TF_IN_AUTOMATION: 1
  CLOUDSMITH_API_KEY: ***
##[endgroup]
info: profile set to 'default'
##[group]Run rustup toolchain install 1.60.0
rustup toolchain install 1.60.0
shell: /usr/bin/bash -e {0}
env:
  AWS_ACCESS_KEY_ID: ***
  AWS_DEFAULT_REGION: us-east-2
  AWS_SECRET_ACCESS_KEY: ***
  CARGO_INCREMENTAL: 0
  CARGO_NET_RETRY: 50
  RUSTDOCFLAGS: -Aunstable-name-collisions --deny warnings
  RUSTFLAGS: -Aunstable-name-collisions --deny warnings -Cdebuginfo=0
  RUSTUP_MAX_RETRIES: 10
  RUST_BACKTRACE: full
  TF_IN_AUTOMATION: 1
  CLOUDSMITH_API_KEY: ***
##[endgroup]
info: syncing channel updates for '1.60.0-x86_64-unknown-linux-gnu'

  1.60.0-x86_64-unknown-linux-gnu unchanged - rustc 1.60.0 (7737e0b5c 2022-04-04)

info: checking for self-updates
warning: tool `rustfmt` is already installed, remove it from `/home/runner/.cargo/bin`, then run `rustup update` to have rustup manage this tool.
warning: tool `cargo-fmt` is already installed, remove it from `/home/runner/.cargo/bin`, then run `rustup update` to have rustup manage this tool.
##[group]Run which rustfmt
which rustfmt
shell: /usr/bin/bash -e {0}
env:
  AWS_ACCESS_KEY_ID: ***
  AWS_DEFAULT_REGION: us-east-2
  AWS_SECRET_ACCESS_KEY: ***
  CARGO_INCREMENTAL: 0
  CARGO_NET_RETRY: 50
  RUSTDOCFLAGS: -Aunstable-name-collisions --deny warnings
  RUSTFLAGS: -Aunstable-name-collisions --deny warnings -Cdebuginfo=0
  RUSTUP_MAX_RETRIES: 10
  RUST_BACKTRACE: full
  TF_IN_AUTOMATION: 1
  CLOUDSMITH_API_KEY: ***
##[endgroup]
/home/runner/.cargo/bin/rustfmt
##[group]Run rustfmt --version
rustfmt --version
shell: /usr/bin/bash -e {0}
env:
  AWS_ACCESS_KEY_ID: ***
  AWS_DEFAULT_REGION: us-east-2
  AWS_SECRET_ACCESS_KEY: ***
  CARGO_INCREMENTAL: 0
  CARGO_NET_RETRY: 50
  RUSTDOCFLAGS: -Aunstable-name-collisions --deny warnings
  RUSTFLAGS: -Aunstable-name-collisions --deny warnings -Cdebuginfo=0
  RUSTUP_MAX_RETRIES: 10
  RUST_BACKTRACE: full
  TF_IN_AUTOMATION: 1
  CLOUDSMITH_API_KEY: ***
##[endgroup]
error: 'rustfmt' is not installed for the toolchain '1.60.0-x86_64-unknown-linux-gnu'
To install, run `rustup component add rustfmt --toolchain 1.60.0-x86_64-unknown-linux-gnu`
##[error]Process completed with exit code 1.

Note that if we use rustup set profile minimal and rustup toolchain install 1.60.0 --components rustfmt, then rustfmt gets to be downloaded 🤔

Steps

We assume the environment is clean (e.g. bare github runner)

Create a rust-toolchain file with the contents:

1.60.0

Run the following commands:

rustup show
rustup -V
rustup set profile default
rustup toolchain install 1.60.0
which rustfmt
rustfmt --version

You will see that rustup show downloads some components, and rustfmt --version fails with exit code 1:

error: 'rustfmt' is not installed for the toolchain '1.60.0-x86_64-unknown-linux-gnu'
To install, run `rustup component add rustfmt --toolchain 1.60.0-x86_64-unknown-linux-gnu`

Rustup version

rustup 1.24.3 (ce5817a94 2021-05-31)

Installed toolchains

Nice joke, rustup show is what is broken itself :wink:

Veetaha avatar Jun 21 '22 10:06 Veetaha

See discussion in https://github.com/rust-lang/rustup/issues/1397. I agree that it's surprising and (in my opinion) undesirable behavior.

yerke avatar Jul 07 '22 04:07 yerke