rust-lang / rustup

The Rust toolchain installer
https://rust-lang.github.io/rustup/
Apache License 2.0
6.13k stars 882 forks source link

Toolchain override for specific cargo subcommand #762

Open dzamlo opened 7 years ago

dzamlo commented 7 years ago

The idea is that you can override the toolchain used to run a specific cargo sub-command.

My use case is running cargo clippy while using the stable toolchain for everything else. There is a workaround: rustup run nightly cargo clippy, but its pretty annoying. With this functionality I could override the toolchain for the clippy sub-command while still using the stable toolchain for the everything else..

Luthaf commented 7 years ago

A thing I recently found in the code, and I do not think is documented, is that you can add +<toolchain> in the command line to select a toolchain for a specific command:

cargo +nightly clippy
cargo +beta test --lib

As it is not documented, it might not be something we can rely on, but this is a less verbose way to use an alternative toolchain.

vitiral commented 7 years ago

can the cargo +<toolchain> be documented somewhere? I love it!

pnkfelix commented 7 years ago

@vitiral I think it is documented here in the rustup.rs README?

jedahan commented 6 years ago

Hmm this is no longer working for me

 ▲ ~ cargo +nightly bench
error: no such subcommand: `+nightly`
dzamlo commented 6 years ago

It still works for me. Are you sure you are using the rustup version of cargo and the normal one?

jedahan commented 6 years ago

I think I am using the one installed via homebrew (brew info rust shows rust: stable 1.25.0 (bottled), HEAD)

~ cargo version
cargo 0.25.0
vitiral commented 6 years ago

I'm not on mac, but if you are a dev it is recommended to install rustup instead of cargo/rust directly.

tmplt commented 4 years ago

This is certainly not the correct issue, but if anyone else using NixOS also stumbles upon this issue:

I had both rustup and cargo in my system packages, which yielded

$ cargo expand
error: no such subcommand: `+nightly`

Removing cargo (and effectively using the binary shipped with rustup instead) fixed the issue.