Cargo config to use nightly

Is there any way to set a project to use nightly (or any toolchain) via a project's cargo.toml? I know how to set an override for a project via the rustup override command, but it seems strange to me that rustup overrides would be the only way to do this. It seems to me that actually requiring nightly is a property of a project, not a property of the machine or path that it is compiled from. So it would be good if projects had a way to specifically declare that they are built with nightly.

My motivations for this are:

  • I have a few projects that use unstable features
  • occasionally, I rename projects, or change where I store them, and the overrides need to be updated to use the new path
  • if I ever work from a different computer, then I have to set up the override for each project on the new PC

No it is impossible to do this with any cargo configuration. However, rustup has many configuration options. You can create and commit a rust-toolchain.toml file. In it you can specify the exact night version your project plus extra components (like clippy) you want to have available. rustup Downloads and installs the correct tool chain the first time you run a command in that folder. It is not a cargo config, but it should solve all your use cases.


Thank you, that does perfectly solve it.
It took me a bit of rereading the section you linked, to realise that I don't need to pin a version, either. I can just put channel = "nightly"

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.