本篇是安装rust时遇到的问题
当执行以下语句时:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
报错:
info: downloading installer
Welcome to Rust!
This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.
Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:
。。。。。。(省略一大段)
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1
error: could not amend shell profile: '/Users/jeannie/.bash_profile': could not write rcfile file: '/Users/jeannie/.bash_profile': Permission denied (os error 13)
解决方法:
- 进入该路径:cd /Users/自己电脑的用户名
- 修改报错信息上的文件权限,报错信息上是.bash_profile,所以就修改这个文件:chmod 777 .bash_profile
- 又报错:chmod: Unable to change file mode on .bash_profile: Operation not permitted
- 在以上述命令之前增加一个sudo命令:sudo chmod 777 .bash_profile
- 查看一下权限:ls -l .bash_profile
文件权限修改成功!接下来就可以正常执行rust安装命令了。
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
info: downloading installer
Welcome to Rust!
This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.
# ... lots of output
Current installation options:
default host triple: x86_64-unknown-linux-gnu
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
> 1
... lots of output
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'
stable-x86_64-unknown-linux-gnu installed - rustc 1.59.0 (9d1b2106e 2022-02-23)
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, run:
$ source $HOME/.cargo/env
$ source $HOME/.cargo/env
$ rustc --version
rustc 1.62.0 (a8314ef7d 2022-06-27)
$ cargo --version
cargo 1.62.0 (a748cf5a3 2022-06-08)
# note: since you live in the future, your version may be more recent
本文参考文章:
- https://blog.csdn.net/RogerQianpeng/article/details/134866272
- https://blog.csdn.net/m0_60437766/article/details/133918533