How can I handle version issues with multiple Rust projects?

I have many Rust projects locally, and I need to perform operations like cargo fmt on them. However, I find that because each project uses different versions, every time I execute the fmt operation, it downloads the corresponding Rust version and toolchain, which consumes a lot of disk space and wastes download time.

one project:

 cargo fmt
info: syncing channel updates for 'nightly-2023-10-08-aarch64-apple-darwin'
info: latest update on 2023-10-08, rust version 1.75.0-nightly (97c81e1b5 2023-10-07)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'

another project:

cargo fmt                                                       
info: syncing channel updates for '1.87.0-aarch64-apple-darwin'
info: latest update on 2025-05-15, rust version 1.87.0 (17067e9ac 2025-05-09)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-std'
info: downloading component 'rustc'
......

Is there a good way to make all Rust projects use the same version (similar to rustup default nightly-2025-09-10)?

The behavior you are seeing indicates that the project directories has a toolchain override configured, most likely using the file rust-toolchain.toml.

Most Rust projects should not be selecting specific old toolchains. Overriding to β€œpin” a specific nightly toolchain version can be necessary when the project uses unstable features, but in other cases it should not be done.

You can delete the rust-toolchain.toml file or change its contents to specify channel = "stable" or a newer version, as you see fit. Or, you can override for any individual command, like this: cargo +stable fmt

You may also be interested in turning off toolchain auto-installation, if you would rather have operations fail than install additional toolchains: rustup set auto-install disable

6 Likes

Thank you for your suggestion.