How can we completely remove Rust installed by Ubuntu?

Viewed 3580

I want to update my Rust to latest but when I searched for rustup it was not showing up in my system rustup: command not found. I tried to install rustup using curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh. It gave this warning.

warning: rustup should not be installed alongside Rust. Please uninstall your existing Rust first.
warning: Otherwise you may have confusion unless you are careful with your PATH
warning: If you are sure that you want both rustup and your already installed Rust
warning: then please reply `y' or `yes' or set RUSTUP_INIT_SKIP_PATH_CHECK to yes

I tried to remove rustc with sudo apt remove rustc but it returns

Package 'rustc' is not installed, so not removed

although I can access rustc from terminal. My current rustc and cargo version is 1.47.0.

1 Answers

You can do this without manually deleting the old rust binaries by uninstalling cargo and then auto-removing its now un-needed dependencies:

sudo apt remove cargo
sudo apt autoremove

After that completes, you should be able to run the rustup installation script normally:

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

Remember that you may need to restart your shell or logout before your system PATH will be updated to include the new binaries.

Related