解决使用Rustup在Linux或macOS上无法安装Rust(Permission denied (os error 13))

错误

使用 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)
Rust安装的Permission denied (os error 13)错误
Rust 安装的 Permission denied (os error 13) 错误

这是由于 .profile.bashrc 的权限不允许写入所导致的。

解决

只需给上述提到的文件加入权限即可。将修改为777权限,即在对应目录运行 chmod 777 .profilechmod 777 .bashrc,之后再运行rustup,问题得以解决。

在Linux上成功安装Rust
在 Linux/macOS 上成功安装Rust

《解决使用Rustup在Linux或macOS上无法安装Rust(Permission denied (os error 13))》有2条评论

回复 itdevwu 取消回复