你提到的“Debian Rust错”比较笼统,一般是指在 Debian 系统上安装 / 编译 / 运行 Rust 时出错。下面按常见场景给你一份排查和解决指南。
apt 安装的 Rust(不推荐)sudo apt install rustc cargo
常见问题:
✅ 解决建议(强烈推荐):
sudo apt remove rustc cargo
然后改用官方方式安装:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
error: linker 'cc' not found这是 最常见 的 Debian 错误。
原因:缺少 C 编译器和链接器。
✅ 解决:
sudo apt update
sudo apt install build-essential
验证:
cc --version
could not find system library例如:
could not find system library 'ssl'
✅ 解决(示例):
sudo apt install libssl-dev pkg-config
其它常见依赖:
sudo apt install libclang-dev clang
GLIBC / symbol not found原因:
✅ 解决:
musl 静态编译:rustup target add x86_64-unknown-linux-musl
cargo build --target x86_64-unknown-linux-musl
permission denied 或 ~/.cargo 权限问题✅ 解决:
sudo chown -R $USER:$USER ~/.cargo ~/.rustup
| Debian | Rust apt 版本 | 建议 |
|---|---|---|
| Debian 10 | 很旧 | 用 rustup |
| Debian 11 | 旧 | 用 rustup |
| Debian 12 | 稍好 | rustup 仍推荐 |
rustc --version
cargo --version
cc --version
pkg-config --version
如果前两个 OK,但 cc 没有 → 99% 是链接器问题。
你可以贴出:
cat /etc/os-release)我可以直接帮你“对症下药”。