---
title: How to Uninstall Rust Completely
summary: 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.
lang: en
slug: how-to-uninstall-rust-completely
published: 2026-04-17T16:32:01+00:00
updated: 2026-04-25T22:00:13+00:00
canonical: https://www.rustfaq.org/en/how-to-uninstall-rust-completely/
---

# How to Uninstall Rust Completely



## The workshop is closed

You installed Rust six months ago to build a CLI tool. The tool is done. The `cargo` command is still hanging around in your PATH, and `rustup` is quietly downloading updates in the background. Or maybe you tried the official installer, realized your company mandates `apt` or `brew`, and now you have two conflicting Rust installations fighting over the same binaries. You need to wipe the slate clean.

Removing Rust is not like deleting a single application file. Rust's standard installation uses a toolchain manager called `rustup`. This manager controls the compiler, the build tool, the package registry, and a cache of downloaded crates. Uninstalling Rust means removing the manager, the tools it controls, the cached data, and the environment variables that tell your shell where to find everything.

## What rustup actually installs

When you run the official installer, `rustup` sets up a directory structure in your home folder. On Unix-like systems, this is `~/.rustup` and `~/.cargo`. On Windows, it is `%USERPROFILE%\.rustup` and `%USERPROFILE%\.cargo`.

The `~/.rustup` directory holds the toolchains. Each toolchain is a snapshot of the Rust compiler and standard library for a specific version. If you have stable, beta, and nightly installed, they all live here. This directory also contains `settings.toml`, which tracks your default toolchain and other preferences.

The `~/.cargo` directory holds the cargo registry and the binary directory. The registry caches every crate you have ever downloaded. This cache can grow to several gigabytes over time. The `bin` subdirectory contains the symlinks or wrappers for `cargo`, `rustc`, `rustup`, and other tools. Your shell's PATH points here so you can run these commands from anywhere.

`rustup` also modifies your shell configuration files. It adds lines to `.bashrc`, `.zshrc`, or `.profile` that set environment variables like `CARGO_HOME` and `RUSTUP_HOME`, and it ensures the cargo bin directory is on your PATH. Some older installations source a helper script from `~/.cargo/env`. Newer installations patch the shell config directly.

Rust is more than a compiler. It is a managed ecosystem. Removing it means removing the manager, the tools, and the cache.

## The uninstall command

The official way to remove Rust is to invoke the uninstaller built into `rustup`. This script knows exactly where the files are and how to clean up the environment.

```bash
# Invoke the rustup binary to remove itself and all managed toolchains.
# This command prompts for confirmation before deleting files.
rustup self uninstall
```

The command asks for confirmation. It lists the directories it will remove. If you confirm, it deletes the toolchains, the registry, the binaries, and attempts to remove the environment variable lines from your shell configuration.

Run the command. Confirm the deletion. Do not skip the verification step.

## What happens behind the scenes

When `rustup self uninstall` runs, it performs a sequence of cleanup operations. First, it locates the `~/.rustup` directory. It iterates through every installed toolchain and removes the compiler binaries and standard library files. It deletes the `settings.toml` file.

Next, it targets `~/.cargo`. It removes the `registry` directory, which frees up the cached crates. It removes the `bin` directory, which removes the command wrappers. If you have built projects that left artifacts in `~/.cargo`, those are also removed.

The uninstaller then scans your shell configuration files. It looks for lines that reference `cargo` or `rustup`. It removes lines that export `PATH` with `~/.cargo/bin`. It removes lines that source `~/.cargo/env`. It removes lines that set `CARGO_HOME` or `RUSTUP_HOME`. The exact behavior depends on your shell. Bash and Zsh are well supported. Fish and PowerShell have their own handling.

On Windows, the uninstaller removes the directories in `%USERPROFILE%`. It also attempts to remove environment variables from the user environment block. This requires administrative privileges in some cases, or it may only remove variables for the current user.

The uninstaller handles the heavy lifting. Your job is to check for leftovers.

## Cleaning up the remnants

The uninstaller is thorough, but it is not perfect. Shell configuration files can contain custom modifications that the script does not recognize. If you manually edited your `.zshrc` to add Rust paths, the uninstaller will not remove those lines. If you have multiple shell configs, the script might only patch the one it detects.

After the uninstaller finishes, open your shell configuration files. Search for `cargo`, `rustup`, `RUSTUP_HOME`, and `CARGO_HOME`. Delete any lines that reference these. Restart your terminal to reload the config.

```bash
# Check for residual environment variables in the current session.
# These variables should be empty or unset after a clean uninstall.
echo $CARGO_HOME
echo $RUSTUP_HOME

# Verify the binaries are gone.
# A clean uninstall returns "command not found" or similar.
which rustc
which cargo
which rustup
```

On Windows, open the System Properties dialog. Navigate to Environment Variables. Check the User variables for `CARGO_HOME` and `RUSTUP_HOME`. Remove them if they exist. Check the `Path` variable for entries pointing to `%USERPROFILE%\.cargo\bin`. Remove those entries.

Ghost environment variables cause subtle bugs. Hunt them down.

## Pitfalls and edge cases

The most common pitfall is mixing installation methods. If you installed Rust via `rustup` and also installed a package via `apt` or `brew`, you have two independent Rust installations. Running `rustup self uninstall` removes the `rustup` installation. It does not touch the package manager installation. You will still have `rustc` and `cargo` available, but they will be managed by the system package manager.

If you try to run `rustup self uninstall` and get `command not found`, you likely never installed `rustup`. You might have installed Rust via a package manager, or the binaries were deleted manually. In this case, you need to use the package manager to remove Rust, or manually delete the directories.

Another pitfall is the cargo registry cache. If you uninstall Rust and then reinstall it, the registry cache is gone. You will need to download all your dependencies again. This can slow down your first build after reinstalling. If you plan to reinstall soon, you can back up `~/.cargo/registry` before uninstalling. Restore it after reinstalling to skip the download step.

Some users keep `~/.cargo` to preserve the registry cache while removing the toolchains. This is not recommended. The registry format can change between versions. Keeping an old cache can lead to corruption or compatibility issues. A clean uninstall removes everything.

Package managers and rustup are strangers. They do not talk to each other.

## Choosing the right removal method

The removal method depends entirely on how you installed Rust. Using the wrong method leaves debris or fails to remove anything.

Use `rustup self uninstall` when you installed Rust via the official installer or the `rustup` toolchain manager. This handles the toolchain cache, the cargo registry, and attempts to clean environment variables.

Use your system package manager when you installed Rust via `apt`, `yum`, `pacman`, or `brew`. The package manager owns the binaries and configuration paths, so `rustup` commands will not exist or will not affect the system installation. Run `apt remove rustc cargo` or `brew uninstall rust` to remove the package.

Use manual directory deletion only as a last resort when the uninstaller is missing or corrupted. This requires you to track down every path and environment variable yourself, which is error-prone. Delete `~/.rustup`, `~/.cargo`, and clean your shell configs.

Use `rustup toolchain uninstall` when you want to remove a specific version of Rust but keep the toolchain manager and other versions. This is useful for freeing disk space without losing your build environment. Run `rustup toolchain uninstall nightly` to remove only the nightly toolchain.

Match the removal method to the installation method. Mixing them leaves debris.

## Where to go next

- [How to Set Up Neovim for Rust Development](/en/how-to-set-up-neovim-for-rust-development/)
- [How to Publish Your First Crate on crates.io](/en/how-to-publish-your-first-crate-on-cratesio/)
- [How to Manage the MSRV (Minimum Supported Rust Version)](/en/how-to-manage-the-msrv-minimum-supported-rust-version/)