Makogan
Makogan

Reputation: 9538

rust-gpu complains about mismatching toolchain file

rust-gpu says:

Copy the rust-toolchain file to your project. (You must use the same version of Rust as rust-gpu.)

So I copied that file into my root getting rust-toolchain with contents:

# If you see this, run `rustup self update` to get rustup 1.23 or newer.

# NOTE: above comment is for older `rustup` (before TOML support was added),
# which will treat the first line as the toolchain name, and therefore show it
# to the user in the error, instead of "error: invalid channel name '[toolchain]'".

[toolchain]
channel = "nightly-2022-10-29"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
# commit_hash = 9565dfeb4e6225177bbe78f18cd48a7982f34401

# Whenever changing the nightly channel, update the commit hash above, and make
# sure to change REQUIRED_TOOLCHAIN in crates/rustc_codegen_spirv/src/build.rs also.

Then I tried building by doing cargo-run, getting:

error: failed to run custom build command for `rustc_codegen_spirv v0.4.0-alpha.17 (https://github.com/EmbarkStudios/rust-gpu#fabcbd9c)`

Caused by:
  process didn't exit successfully: `/home/makogan/rust_never_engine/target/debug/build/rustc_codegen_spirv-b4185236522e0515/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=RUSTGPU_SKIP_TOOLCHAIN_CHECK

  --- stderr
  error: wrong toolchain detected (found commit hash `e631891f7ad40eac3ef58ec3c2b57ecd81e40615`, expected `9565dfeb4e6225177bbe78f18cd48a7982f34401`).
  Make sure your `rust_toolchain` file contains the following:
  -------------
  [toolchain]
  channel = "nightly-2022-10-29"
  components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

I am confused, the toolchain file says the same thing as the error message, what did I do wrong?

Upvotes: 0

Views: 201

Answers (1)

cafce25
cafce25

Reputation: 27322

You're running a different version of nightly than the crate requires. To check the version of cargo try to run cargo --version from within the project directory. If it shows anything else than the version you specified in the rust-toolchain file then you can try and check out the list below for possible fixes.

Make sure that:

  1. The cargo you're using is managed by rustup if it is cargo +stable --version should show a version number and not an error.
  2. The rust-toolchain is in the same directory as Cargo.toml if it's not copy or move it there.
  3. There is no override on the crates directory. You can list them with rustup override list if the crate where the error appears is listed you can unset it with rustup override unset from within the crate root.

In this specific case 3. was the culprit.

Upvotes: 3

Related Questions