错误
使用 rustup 在 Linux 服务器或者 macOS 上安装 Rust 时,有时会出现以下错误,导致无法正确安装:
error: could not amend shell profile: '/home/ubuntu/.bashrc'
error: caused by: could not write rcfile file: '/home/ubuntu/.bashrc'
error: caused by: Permission denied (os error 13)
或者
error: could not amend shell profile: '/home/ubuntu/.profile'
error: caused by: could not write rcfile file: '/home/ubuntu/.profile'
error: caused by: Permission denied (os error 13)

这是由于 .profile
和 .bashrc
的权限不允许写入所导致的。
解决
只需给上述提到的文件加入权限即可。将修改为777权限,即在对应目录运行 chmod 777 .profile
和 chmod 777 .bashrc
,之后再运行rustup,问题得以解决。

mac也适用,感谢!🙏
有用就好