cargo-sweep icon indicating copy to clipboard operation
cargo-sweep copied to clipboard

cargo-sweep should ignore custom toolchains

Open jyn514 opened this issue 2 years ago • 1 comments

I installed a custom version of rust from source (with x.py) and then cleaned the target directory. Now cargo sweep -i doesn't work. Instead of giving a hard error, it should just skip custom toolchains and continue sweeping all others.

$ cargo sweep -i
[INFO] Using all installed toolchains: ["stable-x86_64-unknown-linux-gnu", "beta-x86_64-unknown-linux-gnu", "nightly-2021-07-17-x86_64-unknown-linux-gnu", "nightly-2021-07-19-x86_64-unknown-linux-gnu", "nightly-2021-07-23-x86_64-unknown-linux-gnu", "nightly-2021-12-30-x86_64-unknown-linux-gnu", "nightly-x86_64-unknown-linux-gnu", "1.42-x86_64-unknown-linux-gnu", "1.43-x86_64-unknown-linux-gnu", "1.44-x86_64-unknown-linux-gnu", "1.45-x86_64-unknown-linux-gnu", "1.47-x86_64-unknown-linux-gnu", "1.50-x86_64-unknown-linux-gnu", "1.51-x86_64-unknown-linux-gnu", "1.54-x86_64-unknown-linux-gnu", "1.57-x86_64-unknown-linux-gnu", "wasi", "1.46.0-x86_64-unknown-linux-gnu", "1.49.0-x86_64-unknown-linux-gnu", "1.53.0-x86_64-unknown-linux-gnu", "1.55.0-x86_64-unknown-linux-gnu"]
[ERROR] Failed to clean "/home/jnelson/redacted/target": 
$ cargo +wasi -vV
error: toolchain 'wasi' is not installed
$ rustup toolchain list -v | grep -v -
wasi	/home/jnelson/src/rust/out

jyn514 avatar Jan 14 '22 19:01 jyn514

I just checked and rustup prevents you from naming custom toolchains things that could be a version number:

$ rustup toolchain link 1.52.0 /home/jnelson/rust-lang/rust/out
error: invalid custom toolchain name: '1.52.0-x86_64-unknown-linux-gnu'
$ rustup toolchain link beta /home/jnelson/rust-lang/rust/out
error: invalid custom toolchain name: 'beta-x86_64-unknown-linux-gnu'
$ rustup toolchain link stable /home/jnelson/rust-lang/rust/out
error: invalid custom toolchain name: 'stable-x86_64-unknown-linux-gnu'
$ rustup toolchain link nightly /home/jnelson/rust-lang/rust/out
error: invalid custom toolchain name: 'nightly-x86_64-unknown-linux-gnu'

So it should be possible to tell if toolchains are custom by seeing if they match \d+\.\d+(:?\.\d+).* or stable/beta/nightly or not.

jyn514 avatar Jan 14 '22 19:01 jyn514