首页 > 解决方案 > 权限被拒绝在 mac 上编辑 .bash_profile rbenv init

问题描述

在 mac 上运行 rbenv init 时挂断了编辑 .bash_profile。

$ rbenv init
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

但收到消息:-bash: /Users/macbookpro/.bash_profile: Permission denied

.bash_profile:权限被拒绝

我尝试直接编辑 .bash_profile 但收到消息:

您不拥有该文件

我找到了这个命令来查看用户:

$ ls -la ~ | grep bash

表明:

-rw------- 1 macbookpro .bash_history
-rw-r--r-- 1 root       .bash_profile

如果我使用命令打开文件:

$ sudo nano ~/.bash_profile

我想我需要将其添加到 .bash_profile:

$ export PATH="$HOME/.rbenv/bin:$PATH"

或者它只是这个的内在“部分”?另外,我该如何保存或者我们有更简单的解决方案(假装我的名字是 Fname-Lname)?

标签: bashmacosterminalrbenv

解决方案


您需要使用sudo才能~/.bash_profilemacOS.

sudo echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

或者就像你在问题结束时所做的那样。


推荐阅读