Rustup: Toolchain override for specific cargo subcommand

Created on 17 Oct 2016  Â·  8Comments  Â·  Source: rust-lang/rustup

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..

Most helpful comment

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.

All 8 comments

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.

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

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

Hmm this is no longer working for me

 â–² ~ cargo +nightly bench
error: no such subcommand: `+nightly`

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

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

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

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.

Was this page helpful?
0 / 5 - 0 ratings