bongkow

View My GitHub Profile

How to Check, Upgrade, and Manage Rust Versions Using rustup

Rust is constantly evolving with new features, optimizations, and security patches. Keeping your Rust installation up to date ensures you’re taking advantage of the latest improvements. However, you might be concerned about how upgrading Rust affects your existing projects.

In this post, we’ll cover:

  1. How to check your current Rust version
  2. How to install Rust using rustup
  3. How to upgrade Rust using rustup
  4. What happens to existing projects when you upgrade Rust

1. How to Check Your Rust Version

Before upgrading, it’s useful to check which Rust version you’re currently using. Run the following command in your terminal:

rustc --version

This will output something like:

rustc 1.85.0 (2025-02-23)

You can also check the installed version of Cargo (Rust’s package manager):

cargo --version

For more detailed information about your Rust installation and toolchains, run:

rustup show

2. How to Install Rust Using rustup

If you don’t have Rust installed yet, the recommended way to install it is using rustup. rustup is a toolchain installer that makes it easy to manage Rust versions.

Step 1: Download and Install rustup

For Linux and macOS, run:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

For Windows, download and run the installer from rustup.rs.

Step 2: Verify the Installation

After installation, restart your terminal and check that Rust is installed by running:

rustc --version

This should print the installed Rust version.


3. How to Upgrade Rust Using rustup

The easiest and safest way to upgrade Rust is by using rustup, the official Rust toolchain manager.

rustup self update

Step 2: Upgrade Rust to the Latest Stable Version

rustup update stable

Once the update is complete, verify the new Rust version with:

rustc --version

You should see the latest version, confirming that the update was successful.


4. What Happens to Existing Projects When You Upgrade Rust?

Upgrading Rust does not usually break your existing projects because Rust is designed to be highly backward-compatible. However, here’s what you need to know:

Case 1: Your Project Uses the Global Rust Version

Case 2: Your Project Has a Fixed Rust Version (rust-toolchain File)

If your project has a rust-toolchain file in its root directory specifying a specific Rust version (e.g., 1.75.0), then upgrading Rust won’t affect that project. Check if your project has this file:

cat rust-toolchain

If it contains:

1.75.0

Your project will continue using Rust 1.75.0, even if you upgrade Rust globally.

Case 3: You Used rustup override to Set a Local Version

You may have manually set a specific Rust version for a project or directory using:

rustup override set 1.75.0

In this case, even after updating Rust globally, that project will still use Rust 1.75.0. To remove the override and use the latest Rust version, run:

rustup override unset

Case 4: Handling Issues After Upgrading

If you experience issues after upgrading, you can easily revert to an older Rust version:

rustup install 1.75.0
rustup default 1.75.0  # Set this version globally

Or, for a specific project:

rustup override set 1.75.0

Conclusion

By understanding these details, you can confidently keep your Rust installation up to date while ensuring your projects remain stable. Happy coding! 🚀