rustup icon indicating copy to clipboard operation
rustup copied to clipboard

Miri becomes unusable, when it is unavailable and override file is present

Open lukas-code opened this issue 3 years ago • 1 comments

Problem

The tool miri can become unusable from a project with a rust-toolchain.toml, if it is unavailable for the current nightly, even if it is set as a required component like this:

[toolchain]
channel = "nightly"
components = [ "miri" ]

Steps

Prerequisite: miri is unavailable for the latest nighly.

  1. rustup toolchain install nightly --component miri
  2. cargo new my_project
  3. cd my_project, create rust-toolchain.toml file with content from above.
  4. cargo miri -V

Expected behavior

Rustup keeps the most recent nighly with miri, miri is usable.

Actual behavior

Rustup force-updates to the latest nighly, uninstalling miri in the process.

> cargo miri -V
info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
info: latest update on 2022-05-29, rust version 1.63.0-nightly (1fede1753 2022-05-28)
warning: Force-skipping unavailable component 'miri-x86_64-unknown-linux-gnu'
warning: Force-skipping unavailable component 'rust-std-x86_64-unknown-uefi'
info: downloading component 'rust-src'
info: downloading component 'rust-std' for 'x86_64-unknown-none'
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: removing previous version of component 'cargo'
info: removing previous version of component 'clippy'
info: removing previous version of component 'miri'
info: removing previous version of component 'rust-docs'
info: removing previous version of component 'rust-std'
info: removing previous version of component 'rustc'
info: removing previous version of component 'rustfmt'
info: installing component 'rust-src'
info: installing component 'rust-std' for 'x86_64-unknown-none'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
error: the 'miri' component which provides the command 'cargo-miri' is not available for the 'nightly-x86_64-unknown-linux-gnu' toolchain

Possible Solution(s)

  • Make rustup use the latest version with all components listed in rust-toolchain.toml by default; or
  • Add an option to rust-toolchain.toml to disable force update.

Notes

We need to consider, that a component that is listed in the toolchain file might never be never available for a target.

For example, one of my projects rust-toolchain.toml looks like this:

[toolchain]
channel = "nightly"
components = [ "rust-src", "miri" ]
targets = [ "x86_64-unknown-none", "x86_64-unknown-uefi" ]

With the (implicit) component rust-std being unavailable for x86_64-unknown-uefi.

Rustup version

rustup 1.24.3 (2021-11-09)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.63.0-nightly (ebbcbfc23 2022-05-27)`

Installed toolchains

Default host: x86_64-unknown-linux-gnu
rustup home:  /home/lukas/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)

active toolchain
----------------

nightly-x86_64-unknown-linux-gnu (overridden by '/home/lukas/code/miri_unavailable/rust-toolchain.toml')
rustc 1.63.0-nightly (ebbcbfc23 2022-05-27)

lukas-code avatar May 29 '22 14:05 lukas-code

It would be nice to have this not force, I agree - but I don't think it should allow downgrade by default. We have been discussing the possibility of having a rustup toolchain install --toolchainfile $blah or similar so I guess that would be usable in that case; though I'm not sure what would be intuitively correct.

Do you have time to think through the implications of removing force from this behaviour; and/or adding allow-downgrade ?

kinnison avatar Aug 27 '22 10:08 kinnison