rustup时提示“网络连接失败”“无法下载组件”或“缺少Python/curl等依赖”。export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
python3、curl等基础工具,Ubuntu下运行:sudo apt-get install python3 curl
~/.rustup目录后重新执行安装命令。source $HOME/.cargo/env
~/.bashrc(bash)或~/.zshrc(zsh)文件末尾,保存后运行source ~/.bashrc。libssl-dev not found”“pkg-config not installed”或“无法链接动态库”。build-essential(包含gcc、make等):sudo apt-get update && sudo apt-get install build-essential
sudo apt-get install libssl-dev pkg-config clang
cargo build,确认错误消失。cargo build时报“版本冲突”“无法解析依赖”或“缓存损坏”。Cargo.toml中的依赖版本后,运行cargo update同步依赖。target目录(rm -rf target/),清除旧编译文件后重新构建。cargo tree命令检查依赖冲突,手动调整Cargo.toml中的版本要求(如serde = "1.0"改为serde = "~1.0")。sudo apt-get install gcc-arm-linux-gnueabihf
rustup添加目标平台,例如ARMv7:rustup target add armv7-unknown-linux-gnueabihf
~/.cargo/config中指定链接器,例如:[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
scp target/armv7-.../debug/hello user@arm:~),使用ldd检查依赖库是否完整。./target/debug/hello时提示“Permission denied”。chmod命令为可执行文件添加权限:chmod +x ./target/debug/hello
./target/debug/hello即可。feature not available”或“syntax error”。rustup更新到最新稳定版:rustup update stable
rustup default nightly
rustc --version确认更新成功。