setup-rust-toolchain icon indicating copy to clipboard operation
setup-rust-toolchain copied to clipboard

Add option to read version from `rust-version` in `Cargo.toml`

Open nik-rev opened this issue 3 months ago • 0 comments

I use nightly Rust in rust-toolchain.toml to get the nightly version of tools (clippy, rust-analyzer, rustfmt):

toolchain.channel = "nightly-2025-08-24"

But my project is supposed to build on stable rust 1.88. To do this, I set rust-version (MSRV) in Cargo.toml:

[package]
rust-version = "1.88"

In my CI I want to use toolchain of rust-version (stable) for these workflows:

  • cargo check
  • cargo test --workspace

And use the toolchain from rust-toolchain.toml for these workflows:

  • cargo clippy -- -D warnings (rust-toolchain.toml)
  • cargo fmt --check (rust-toolchain.toml)

To do that, I need to duplicate the entire components field from rust-toolchain.toml and I also duplicate the MSRV in the workflows. It would be nice to have a single source of truth for versions

Wanted behaviour

An input to the workflow to specify that I want the rust-version in Cargo.toml to override the version specified in rust-toolchain.toml. components field in rust-toolchain.toml should still be read.

I use your workflow in all of my projects, and I love it! Thanks for making it.

small question

if I have 2 workflows like this that use different toolchains - is it much more expensive than using the same toolchain for all workflows? Considering that they (probably) have to have 2 different caches for each toolchain

nik-rev avatar Aug 27 '25 22:08 nik-rev