-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Problem
I have a project where I'm stuck on Rust 1.67. To update the dependencies I use cargo +stable update with the following .cargo/config.toml:
[resolver]
incompatible-rust-versions = "fallback"This works very well, except recently when updating the dependencies of getrandom@0.3.4. This version of getrandom depends on wasip2 on some wasm target, which I don't use: https://docs.rs/crate/getrandom/0.3.4/source/Cargo.toml#64-66
All versions of wasip2 requires Rust 1.82+ and for the relevant wit-bindgen versions that wasip2 depends on it is the same.
This is not a problem for my project as I don't compile for that target and thus cargo build still works. However, cargo +stable update with the above config will update the version of wit-bindgen to a version using the 2024 edition. This doesn't affect cargo build, but this breaks cargo metadata.
I don't know if I should create another issue for the case where cargo build works, but cargo metadata does not. I had a hard time reproducing this on stable as there isn't any crates using edition 2027+, so I don't know if it has been fixed since 1.67.
Steps
Setup:
$ mkdir /tmp/foo
$ cd /tmp/foo
$ rustup override set 1.67.1
$ cargo init
$ cat > Cargo.toml
[package]
name = "foo"
version = "0.1.0"
edition = "2021"
rust-version = "1.67.1"
[dependencies]
^D
$ cargo add getrandom@=0.3.4
cargo run works, but cargo metadata doesn't:
$ cargo run
...
Hello, world!
$ cargo metadata
warning: please specify `--format-version` flag explicitly to avoid compatibility problems
error: failed to download `wit-bindgen v0.51.0`
Caused by:
unable to get packages from source
Caused by:
failed to parse manifest at `/home/tyilo/.cargo/registry/src/github.com-1ecc6299db9ec823/wit-bindgen-0.51.0/Cargo.toml`
Caused by:
failed to parse the `edition` key
Caused by:
this version of Cargo is older than the `2024` edition, and only supports `2015`, `2018`, and `2021` editions.
Manually downgrading wasip2 can get cargo metadata to work:
$ cargo update -p wasip2 --precise 1.0.1+wasi-0.2.4
Updating crates.io index
Updating wasip2 v1.0.2+wasi-0.2.9 -> v1.0.1+wasi-0.2.4
Updating wit-bindgen v0.51.0 -> v0.46.0
$ cargo run
...
Hello, world!
$ cargo metadata
... (Now works!)
However, running cargo +stable update with incompatible-rust-versions = "fallback" results in cargo metadata breaking:
$ mkdir .cargo
$ cat > config.toml
[resolver]
incompatible-rust-versions = "fallback"
^D
$ cargo +stable update -v
Updating crates.io index
Locking 2 packages to latest Rust 1.67.1 compatible versions
Unchanged getrandom v0.3.4 (available: v0.4.1, requires Rust 1.85)
Unchanged r-efi v5.3.0 (requires Rust 1.68)
Updating wasip2 v1.0.1+wasi-0.2.4 -> v1.0.2+wasi-0.2.9 (requires Rust 1.87.0)
Updating wit-bindgen v0.46.0 -> v0.51.0 (requires Rust 1.87.0)
note: to see how you depend on a package, run `cargo tree --invert <dep>@<ver>`
$ cargo run
Hello, world!
$ cargo metadata
warning: please specify `--format-version` flag explicitly to avoid compatibility problems
error: failed to download `wit-bindgen v0.51.0`
Caused by:
unable to get packages from source
Caused by:
failed to parse manifest at `/home/tyilo/.cargo/registry/src/github.com-1ecc6299db9ec823/wit-bindgen-0.51.0/Cargo.toml`
Caused by:
failed to parse the `edition` key
Caused by:
this version of Cargo is older than the `2024` edition, and only supports `2015`, `2018`, and `2021` editions.
Possible Solution(s)
I think that the update logic should be updated to be:
- Prefer versions that are compatible with
rust-versioninCargo.toml - New: If no such version can be found, prefer versions with an
editionthat existed in the Rust version specified byrust-version - If no such version can be found, use the newest
Notes
No response
Version
cargo 1.93.0 (083ac5135 2025-12-15)