'Set a project to use nightly by default
How do I set a Cargo project to build & run using nightly by default (i.e. cargo build
is actually cargo +nightly build
) without setting nightly as the global default?
This is not the same question as How to switch between Rust toolchains. If you read both questions you'll see that question is asking about switching Rust toolchains globally whereas I want to switch Rust toolchains without changing the global setting.
Solution 1:[1]
With rustup override set nightly
it sets the default for that directory to nightly:
https://rust-lang.github.io/rustup/overrides.html#directory-overrides
Solution 2:[2]
If you want this choice to also be reflected in the repository, as opposed to just local configuration, you can add a rust-toolchain.toml file, for example
[toolchain]
channel = "nightly"
You might also want to set the nightly compiler's version (printed by rustup show
) in the rust-version
field of your cargo.toml, so that dependents which try to build on stable get an error message (since rust-toolchain.toml sets the version for a directory, not a crate).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | C14L |
Solution 2 |