在 Debian 上“卸载 Rust”要看你当初是怎么安装的,不同方式卸载方法不一样。下面按常见情况说明。
rustup 安装的(最常见)如果你之前是用官方脚本安装的:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
直接运行:
rustup self uninstall
执行后:
~/.rustup~/.cargocargo、rustc 等命令✅ 推荐方式,最干净
apt 安装的如果你是用:
sudo apt install rustc cargo
sudo apt remove rustc cargo
如果想连配置一起删:
sudo apt purge rustc cargo
再清理无用依赖:
sudo apt autoremove
sudo snap remove rust
which cargo
which rustc
如果还有输出,比如:
~/.cargo/bin/cargo
可以手动删:
rm -rf ~/.cargo
rm -rf ~/.rustup
并检查 .bashrc / .zshrc 里有没有:
source "$HOME/.cargo/env"
有的话删掉。
cargo --version
rustc --version
都提示 command not found 就说明干净了。
如果你愿意,可以告诉我:
我可以给你精确的一条命令。