我在macOs上执行curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs |sh后的错如下:
error: could not amend shell profile: '/Users/liujianhua/.profile': could not write rcfile file: '/Users/liujianhua/.profile': Permission denied (os error 13)
liujianhuadeiMac:/ liujianhua$
经查资料,是.profile 没有写入权限引起的。
解决方法,给予777的权限
sudo chmod 777 .profile
然后再执行安装,就顺利安装上了。
Rust is installed now. Great!
To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).
To configure your current shell, you need to source
the corresponding env file under $HOME/.cargo.
This is usually done by running one of the following (note the leading DOT):
. "$HOME/.cargo/env" # For sh/bash/zsh/ash/dash/pdksh
source "$HOME/.cargo/env.fish" # For fish
为了确保每次启动终端时都能加载 Rust 环境变量,我们需要将以下内容添加到 .zshrc 文件中。在终端中执行以下命令:
liujianhuadeiMac:~ liujianhua$ echo 'source $HOME/.cargo/env' >> .zshrc
同时添回国内镜像源:
liujianhuadeiMac:Users liujianhua$ echo 'export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static' >> ~/.zshrc
liujianhuadeiMac:Users liujianhua$ echo 'export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup' >> ~/.zshrc
验证:
打开一个新shell
liujianhuadeiMac:~ liujianhua$ rustc -V
rustc 1.77.1 (7cf61ebde 2024-03-27)
liujianhuadeiMac:~ liujianhua$ cargo -V
cargo 1.77.1 (e52e36006 2024-03-26)
liujianhuadeiMac:~ liujianhua$ rustup -V
rustup 1.27.0 (bbb9276d2 2024-03-08)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.77.1 (7cf61ebde 2024-03-27)`
|