Failed to update Rust on my system

On Ubuntu Linux, this is what I did:

\~> rustc --version 
rustc 1.85.1 (4eb161250 2025-03-15) (built from a source tarball)

I then installed rustup:

\~> rustup --version 
rustup 1.27.1 (2025-03-14)
 
\~> sudo rustup update stable 
\[sudo: authenticate\] Password:  
**info:** syncing channel updates for 'stable-x86_64-unknown-linux-gnu' 
**info:** latest update on 2025-12-11, rust version 1.92.0 (ded5c06cf 2025-12-08) 
**info:** downloading component 'cargo' 
**info:** downloading component 'clippy' 
**info:** downloading component 'rust-docs' 
**info:** downloading component 'rust-std' 
**info:** downloading component 'rustc' 
 74.3 MiB /  74.3 MiB (100 %)  54.1 MiB/s in  1s ETA:  0s 
**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' 
 74.3 MiB /  74.3 MiB (100 %)  32.7 MiB/s in  2s ETA:  0s 
**info:** installing component 'rustfmt' 

  **stable-x86_64-unknown-linux-gnu installed** - rustc 1.92.0 (ded5c06cf 2025-12-08) 

**info:** default toolchain set to 'stable-x86_64-unknown-linux-gnu' 
**info:** self-update is disabled for this build of rustup 
**info:** any updates to rustup will need to be fetched with your system package manager 
\~>  
\~> rustup --version 
rustup 1.27.1 (2025-03-14) 
**info:** This is the version for the rustup toolchain manager, not the rustc compiler. 
\~>  
\~> rustc --version 
**error:** rustup could not choose a version of rustc to run, because one wasn't specified explicitly, and no default is configured. 
help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.

\~> sudo rustup default stable 
\[sudo: authenticate\] Password:  
**info:** using existing install for 'stable-x86_64-unknown-linux-gnu' 
**info:** default toolchain set to 'stable-x86_64-unknown-linux-gnu' 

  **stable-x86_64-unknown-linux-gnu unchanged** - rustc 1.92.0 (ded5c06cf 2025-12-08) 

\~> rustc --version 
**error:** rustup could not choose a version of rustc to run, because one wasn't specified explicitly, and no default is configured. 
help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.

\~> ls -a ./.cargo/ 
**.**  **..**  **registry**  .global-cache  .package-cache  .package-cache-mutate
\~> which rustc 
/usr/bin/rustc 
\~>  
\~> type rustc 
rustc is /usr/bin/rustc 
\~>  
\~> locate -b rustc
/home/pietrom/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustc_version-0.4.1 
/home/pietrom/.cargo/registry/src/index.crates.io-6f17d22bba15001f/autocfg-1.5.0/src/rustc.rs 
… /usr/bin/rustc 
/usr/bin/rustc-1.81 
/usr/bin/rustc-1.84 
/usr/bin/rustc-1.85 
…
/usr/lib/rust-1.85/bin/rustc 
/usr/lib/rust-1.85/lib/librustc_driver-498d2b6d02538b82.so 
/usr/lib/rust-1.85/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-9ff52a53bbba3a7a.rlib 
…  
/usr/lib/x86_64-linux-gnu/librustc_driver-f660ce0928bc5f8b.so 
/usr/share/rustc 
/usr/share/rustc-1.81 
/usr/share/rustc-1.84 
/usr/share/rustc-1.85 
/usr/share/cargo/registry/rustc-demangle-0.1.24 
… 
/usr/share/doc/librust-compiler-builtins+rustc-dep-of-std-dev 

What is wrong? Why the latest Rust version (rustc 1.92.0) is not installed, and why I cannot use an old version by default using rustc?

Thank you for your help.

In a normal setup, Rustup is commonly setting up rustc (and other executables, including itself) in the .cargo/bin directory in the user folder. According to Installation - The rustup book, this can be customized

rustup allows you to customise your installation by setting the environment variables CARGO_HOME and RUSTUP_HOME before running the rustup-init executable.

but the path of /usr/bin/rustc seems likely to be a rustc from the system package manager instead. Though I’m not entirely up to date on how package-manager integration of rustup-managed installation is working. For reference, feel free to share some information on how you have installed rustup in the first place :wink:

Besides the .cargo directory, there is the .rustup directory (also in the home directory; corresponding to RUSTUP_HOME) where (in subdirectories if that) the actual binary files for different compiler versions would be installed.


Notably however, as far as I know, the standard instalation does put the rustup-managed compiler in the user’s directory, and is hence nothing that requires root privileges. By executing sudo rustup commands, you might be setting up something in the root user’s home directory? Given, you’re already also running rustup commands (like rustup --version) without sudo, you could certainly just try of rustup default stable without a sudo makes your setup “work” already.[1]

To find out where more of the relevant files of your rustup are currently located [and hence the the .rustup directory], feel free to also try something like rustup which --toolchain stable rustc.[2]

Another thing to try out would be – following the note of the error message that a versions “was not specified explicitly”, to see it doing that would work, i.e. if you execute rustc +stable --version, and that works, then this means

  • you can use rustc that way
  • the rustc command you’re using does indeed appear to be managed by rustup, somehow.

Edit: It looks like an Ubuntu package for rustup does exist nowadays, so perhaps that’s what you’re working with. I have no idea how exact file layout would be that comes with it, but simply trying rustup default stable without the sudo certainly sounds like a reasonable thing to try, following Other installation methods - The rustup book


  1. Making it clean, i.e. removing redundant copies of rustup or the like, is of course still something that you might want to fix, afterwards :slight_smile: ↩︎

  2. And again, this too may be giving a different output with or without sudo. ↩︎

1 Like

maybe you have multiple rustup on your system and the wrong one is linked as the shim for rustc? e.g. check the output of:

$ which rustc
$ which rustup
$ readlink $(which rustc)
3 Likes

That’s a good thing to try, as well @pietrom16. In order for things to work properly, you should get the same path returned from readlink $(which rustc) as from which rustup; for reference, for me this would look as follows (with my username in place of “…USERNAME…”):

~> which rustc
/home/…USERNAME…/.cargo/bin/rustc

~> which rustup
/home/…USERNAME…/.cargo/bin/rustup

~> readlink $(which rustc)
/home/…USERNAME…/.cargo/bin/rustup

Furthermore, given you’re already showing both rustup and sudo rustup commands, you could also compare the output of sudo which rustup, which help identify a second rustup installation for the root user, in case that’s what’s going on.

3 Likes

I’ve tested it in a VM now, out of curiosity. The Ubuntu package for rustup does indeed set up the shims in /usr/bin.

$ which rustc
/usr/bin/rustc
$ which rustup
/usr/bin/rustup
$ sudo which rustup
/usr/bin/rustup
$ readlink $(which rustc)
rustup
$ 
$ # after having done both "rustup default stable" and "sudo rustup default stable":
$ 
$ rustup toolchain list -v
stable-x86_64-unknown-linux-gnu (default)	/home/…USERNAME…/.rustup/toolchains/stable-x86_64-unknown-linux-gnu
$ 
$ sudo rustup toolchain list -v
stable-x86_64-unknown-linux-gnu (default)	/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu

So it looks like the sudo was indeed the problem for you, as it uses a .rustup folder in /root then. Just do rustup default stable without any sudo to get your rustc (and more importantly, cargo :wink:) command(s) working nicely.

If you want to clean up a bit, you can remove the default for the root user again with sudo rustup default none and uninstall the copy of the stable toolchain for the root user with sudo rustup toolchain uninstall stable; and/or feel free to delete the entire /root/.rustup directory, which would after these commands this point only contain the default config, and 3 empty directories, anyway.

1 Like