askvity

How to Update Rust in Ubuntu?

Published in Rust Update 3 mins read

To update Rust in Ubuntu when it has been installed using the system's package manager, apt, you will use the apt command line utility. This method is applicable if you initially installed Rust using a command like sudo apt install rustc, as described in some installation guides.

Steps to Update Rust via Apt

If you installed Rust using Ubuntu's apt package manager, follow these steps to get the latest version available in the Ubuntu repositories:

  1. Update Package Lists:
    First, refresh the list of available packages and their versions from the Ubuntu repositories. This ensures your system knows if a newer version of Rust is available.

    sudo apt update

    This step corresponds to updating the package registry, preparing your system to recognize available package updates.

  2. Upgrade Rust Compiler:
    After updating the package lists, you can upgrade the installed Rust compiler (rustc) package to the latest version found in the repositories.

    sudo apt upgrade rustc

    This command specifically targets the rustc package for an upgrade, pulling down and installing the newer version if available.

Verify Your Rust Version

Once the upgrade process is complete, it's recommended to verify that Rust has been updated to the expected version.

You can check the currently installed version of the Rust compiler using the following command in your terminal:

rustc --version

Compare the output version number with the latest available version you expected to install from the Ubuntu repositories. This confirms the update was successful. This step is similar to verifying the installation after the initial setup.

Note on Installation Methods

It's worth noting that the official and most common way to install and manage multiple Rust versions on Linux is using rustup. If you installed Rust using rustup, you would typically update it by simply running rustup update. However, the method detailed above focuses on updating Rust specifically when it was installed using the apt package manager, aligning with the installation context provided in guides using sudo apt install rustc. The version available via apt might lag behind the latest official releases available through rustup.

Related Articles