curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
上边的很熟悉了, rust的安装命令, 但国内连接起来非常不方便, 有的时候根本没有办法下载到任何东西。
改为以下命令, 输出到test.sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh > test.sh
进入test.sh当中, 把RUSTUP_UPDATE_ROOT的值改成国内的镜像地址:
# If RUSTUP_UPDATE_ROOT is unset or empty, default it. RUSTUP_UPDATE_ROOT="https://mirrors.ustc.edu.cn/rust-static/rustup"
保存, 退出编辑, 接下来运行下面的命令。
export RUSTUP_DIST_SERVER="https://mirrors.ustc.edu.cn/rust-static" export RUSTUP_UPDATE_ROOT="https://mirrors.ustc.edu.cn/rust-static/rustup"
开始安装
bash ./test.sh
更新rust
rustup self update && rustup update
卸载rust的命令
rustup self uninstall
cargo crates的国内镜像列表
中科大
tee $HOME/.cargo/config <<-'EOF' [source.crates-io] registry = "https://github.com/rust-lang/crates.io-index" replace-with = 'ustc' [source.ustc] registry = "git://mirrors.ustc.edu.cn/crates.io-index" EOF
阿里云
tee $HOME/.cargo/config <<-'EOF' [source.crates-io] replace-with = "rustcc" [source.rustcc] registry = "https://code.aliyun.com/rustcc/crates.io-index" EOF
苹果M1~M3 arm架构编译不了rust的tokio周边库
这个坑很早以前就有人发现, 并提出来issue, 官方其实管不起的。谁叫苹果搞这个事情呢。为了解决类似的问题,苹果拿出的解决方案是rosetta2,剩下的由开发者自己想象。如果你是用终端执行rust编译指令, 按照如下去做:
先卸载你mac电脑里的rust。
rustup self uninstall
卸载干净之后, 退出终端, 在访达->应用程序里面找到终端.app右键点击, 详细简介->使用rosetta打开。
这个时候, 是模拟到x86的平台上了, 进终端执行rust安装指令
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
会发现默认推荐的是安装x86_64版本的rust, 这就意味着你再想在M系列芯片上跑arm的rust很有可能还得在终端里折腾一回(除非docker之类的虚拟机硬上)。 小编亲测可以跑通。