温馨提示×

如何卸Debian的Rust

小樊
33
2026-09-11 03:46:38
栏目: 编程语言

在 Debian 上“卸载 Rust”要看你当初是怎么安装的,不同方式卸载方法不一样。下面按常见情况分别说明。


一、如果你是用 rustup 安装的(最常见)

1. 卸载 rustup 及所有 Rust 工具链

rustup self uninstall

执行后:

  • rustc
  • cargo
  • 所有 toolchain(stable / beta / nightly) 都会被删除

2. 清理环境变量(如有)

编辑你的 shell 配置文件:

nano ~/.bashrc
# 或
nano ~/.zshrc

删除类似内容:

export PATH="$HOME/.cargo/bin:$PATH"

然后:

source ~/.bashrc

二、如果你是用 apt 安装的(系统 Rust)

1. 查看已安装的 Rust 包

dpkg -l | grep rust

2. 卸载 Rust 相关包

常见包名:

sudo apt remove --purge rustc cargo

如果还装了很多依赖:

sudo apt autoremove --purge

三、如果你用了 snap

snap list | grep rust
sudo snap remove rust

四、如果你用了 asdf / nix / 手动编译

asdf

asdf uninstall rust <version>
asdf plugin remove rust

nix

nix-env -e rustc cargo

手动安装(/usr/local)

删除:

sudo rm -rf /usr/local/rust
sudo rm /usr/local/bin/rustc /usr/local/bin/cargo

五、确认是否卸载干净

which rustc
which cargo
rustc --version

如果都提示 command not found,说明已卸载成功。


如果你愿意,可以告诉我:

  • which rustc
  • rustc --version
  • 当初怎么装的(apt / rustup / 其他)

我可以帮你精确卸载,不误删系统组件

0