"sparse registry" breaking my CI and I don't understand why?

Hi! It seems that some "sparse registry" feature is breaking my CI jobs and I don't understand why that is.

Here's the job output (from one week ago):

Run cargo check --tests --examples
error: failed to get `async-trait` as a dependency of package `config-rs-ng v0.1.0 (/home/runner/work/config-rs-ng/config-rs-ng)`

Caused by:
  failed to load source for dependency `async-trait`

Caused by:
  Unable to update registry `crates-io`

Caused by:
  usage of sparse registries requires `-Z sparse-registry`
Error: Process completed with exit code 101.

I am running my CI with Rust 1.60.0, stable and beta. This particular job is 1.60.0.

Can someone explain what I am doing wrong?

The problem is that you are not actually using rust 1.60.0 due to the contents of your rust-toolchain.toml file (see this info note). You are installing Rust 1.60.0, but 1.66 ends up being used anyway. This then conflicts with dtolnay/rust-toolchain's way to conditionally set CARGO_REGISTRIES_CRATES_IO_PROTOCOL: it checks if the toolchain being installed is 1.66 or 1.67 (which is not the case for you) and otherwise sets the flag. This assumes that if you're installing an old version you're using that old version, and there the flag will be ignored because not yet implemented. However you end up actually using rust 1.66 and thus the flag is read and breaks your CI because it's nightly only.

To fix the actual issue (running rust 1.66 instead of 1.60) you can either explicitly set the toolchain in the command (cargo +${{ matrix.rust }} check for each command) or set the RUSTUP_TOOLCHAIN environment variable to ${{ matrix.rust }}. Both will override your rust-toolchain.toml.


Thanks a lot, looks like that solved my issue!

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.