1

I was trying to upgrade rust. I tried uninstalling (1.60.0) and reinstalling. The new version is 1.73.0. But when I ran rustc it automatically downloaded 1.60.0 and reverted to 1.60.0. Wonder how can I force it to use the new version?

info: profile set to 'default'
info: default host triple is aarch64-apple-darwin
info: syncing channel updates for 'stable-aarch64-apple-darwin'
info: latest update on 2023-10-05, rust version 1.73.0 (cc66ad468 2023-10-03)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
 54.4 MiB /  54.4 MiB (100 %)  27.7 MiB/s in  2s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 13.8 MiB /  13.8 MiB (100 %)   5.5 MiB/s in  1s ETA:  0s
info: installing component 'rust-std'
 24.5 MiB /  24.5 MiB (100 %)  21.1 MiB/s in  1s ETA:  0s
info: installing component 'rustc'
 54.4 MiB /  54.4 MiB (100 %)  23.3 MiB/s in  2s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-aarch64-apple-darwin'

  stable-aarch64-apple-darwin installed - rustc 1.73.0 (cc66ad468 2023-10-03)


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, run:
source "$HOME/.cargo/env"

(base) % rustc -V
info: syncing channel updates for '1.60.0-aarch64-apple-darwin'
info: latest update on 2022-04-07, rust version 1.60.0 (7737e0b5c 2022-04-04)
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'
rustc 1.60.0 (7737e0b5c 2022-04-04)
1
  • 1
    There is very likely a rustup version override in the environment or on the directory where you ran rustc -V Commented Oct 6, 2023 at 14:04

1 Answer 1

4

There are a few ways rust could be forced to using a specific compiler version (overrides)

1. The RUSTUP_TOOLCHAIN environment variable

2. A Directory override

Directories can be assigned their own Rust toolchain with rustup override. When a directory has an override then any time rustc or cargo is run inside that directory, or one of its child directories, the override toolchain will be invoked.

The per-directory overrides are stored in a configuration file in rustup's home directory.

To see the active toolchain use rustup show and rustup override unset to remove it.

3. The toolchain file

(rust-toolchain.toml or rust-toolchain) can set a specific Rust version.

For example

[toolchain]
channel = "nightly-2020-07-10"
...

4. The default version can be set directly.

Use rustup default to view the default global toolchain.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, in my case, it turns out to be 3. There is a rust-toolchain.toml in the parent directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.