【问题标题】:Could not write to .bash_profile when installing Rust on macOS Sierra在 macOS Sierra 上安装 Rust 时无法写入 .bash_profile
【发布时间】:2017-08-26 21:28:34
【问题描述】:

我正在尝试通过运行以下命令来安装 Rust:

sudo curl https://sh.rustup.rs -sSf | sh

我不断收到以下错误:

could not write rcfile file: '/Users/pro/.bash_profile'
info: caused by: Permission denied (os error 13

【问题讨论】:

  • 为什么你(试图)以 root 身份运行它?
  • 因为当我在没有它的情况下尝试它时给出了这个错误所以我认为使用 sudo 可以解决它
  • 是不是说不使用sudo也会报错?请edit 你的问题有你正在运行的完整的shell 命令,从curl 命令开始直到下一个shell 提示符。

标签: macos terminal rust


【解决方案1】:

尝试使用这个而不是使用 sudo:

curl https://sh.rustup.rs -sSf | sh -s -- --help

如果可行,那么您可能可以尝试:

curl https://sh.rustup.rs -sSf | sh -s -- --no-modify-path 

如果带有 --no-modify-path 选项的命令有效,您必须手动更新 .bash_profile 以将其包含在您的路径中:

source ~/.cargo/env

【讨论】:

  • 谢谢,这似乎有效。我需要手动编辑路径吗?如果是,我需要将其更改为什么路径?
  • 谢谢你想通了。必须将 source ~/.cargo/env 添加到我的 .bash_profile
  • 黄金!我将更新答案以包含修改路径的附加步骤。
【解决方案2】:

接受的答案仅在工作终端会话中对我有用,在重新启动我的 MacBokk Air 后它不起作用。

与我合作的解决方案是:

// Opened .bash_profile file, I used VS code as editor, this the `code` below
Hasans-Air:~ h_ajsf$ sudo code $HOME/.bash_profile
// Add the below to the .bash_profile file
PATH=$PATH:/Users/$USER/.cargo/bin
//Saved the file
//Updated env by:
Hasans-Air:~ h_ajsf$ source $HOME/.bash_profile
//Check for JAVA_HOME
Hasans-Air:~ h_ajsf$ rustup

更新

如图here

听起来运行安装脚本的用户没有 权限/不是 ~/.bash_profile 的所有者,这是不寻常的。也许 纱线应该检查并更有帮助,但无论如何它可能是 运行sudo chown whoami ~/.bash_profile

的好主意

所以,我尝试了以下命令:

sudo chown h_ajsf ~/.bash_profile

一切顺利完成。

【讨论】:

    猜你喜欢
    • 2017-04-19
    • 2017-06-16
    • 2017-01-29
    • 2017-06-02
    • 2017-02-03
    • 2018-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多