How to Uninstall Rust Completely

To completely remove Rust from your system, you must run the official uninstaller script `rustup self uninstall`, which removes the toolchain, the `rustup` manager, and the associated environment variables.

To completely remove Rust from your system, you must run the official uninstaller script rustup self uninstall, which removes the toolchain, the rustup manager, and the associated environment variables. After running the script, you should manually delete the remaining configuration files in your home directory and verify that the cargo and rustc commands are no longer accessible.

Execute the uninstaller in your terminal. This script handles the removal of binaries, libraries, and the default installation directory (usually ~/.cargo on Unix or %USERPROFILE%\.cargo on Windows).

# Run the official uninstaller
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --uninstall

# If you are on Windows and the script fails, try running it directly from the cargo bin directory:
# C:\Users\<YourUser>\.cargo\bin\rustup.exe self uninstall

Once the script finishes, you need to clean up residual configuration files that the script might leave behind, specifically the .cargo directory and the .rustup directory. On Linux and macOS, run the following commands to ensure a clean slate:

# Remove remaining directories
rm -rf ~/.cargo
rm -rf ~/.rustup

# Remove environment variable exports from your shell profile
# Edit ~/.bashrc, ~/.zshrc, or ~/.profile and delete lines containing:
# export PATH="$HOME/.cargo/bin:$PATH"
# source "$HOME/.cargo/env"

On Windows, you can manually delete the .cargo folder in your user profile (C:\Users\<YourUser>\.cargo) and remove the CARGO_HOME and RUSTUP_HOME environment variables via the System Properties settings.

Finally, verify the removal by opening a new terminal session (to reload your shell profile) and checking if the binaries still exist:

which rustc
which cargo
# If installed, these should return "command not found" or similar errors.

If you previously installed Rust via a package manager like apt, brew, or choco rather than rustup, you must uninstall it using that specific manager (e.g., brew uninstall rust or apt remove rustc) instead of the rustup script, as the package manager manages the files differently. However, for the vast majority of users who installed via the standard website installer, the rustup self uninstall method is the definitive solution.