error: could not amend shell profile: ‘/Users/jeannie/.bash_profile‘:Permission denied (os error 13)

本篇是安装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)

解决方法:

  1. 进入该路径:cd /Users/自己电脑的用户名
  2. 修改报错信息上的文件权限,报错信息上是.bash_profile,所以就修改这个文件:chmod 777 .bash_profile
  3. 又报错:chmod: Unable to change file mode on .bash_profile: Operation not permitted
  4. 在以上述命令之前增加一个sudo命令:sudo chmod 777 .bash_profile
  5. 查看一下权限: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

本文参考文章:

  1. https://blog.csdn.net/RogerQianpeng/article/details/134866272
  2. https://blog.csdn.net/m0_60437766/article/details/133918533
  • 7
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值