简体   繁体   中英

Permission denied editing .bash_profile rbenv init on mac

Hung up on editing the .bash_profile while running rbenv init on mac.

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

but get the message: -bash: /Users/macbookpro/.bash_profile: Permission denied

.bash_profile:权限被拒绝

I try to edit the .bash_profile directly but get the message:

您没有文件“ .bash_profile”

I found this command to see the users:

$ ls -la ~ | grep bash

It shows:

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

If I open the file using command:

$ sudo nano ~/.bash_profile

I guess I need to add this to .bash_profile:

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

Or is it just the inner "part" of this? Also how do I save this or do we have any easier solution (pretending my name is Fname-Lname)?

You'll need to use sudo in order to edit/append ~/.bash_profile on macOS .

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

Or just as you had done at the end of your question.

I was having the same issue what i did was i gave .bash_profile writable permission.

cd ~
sudo chmod 0777 .bash_profile
nano .bash_profile

After adding your modifcations you can now save the file with ^O and enter (return) after that you use ^x to exit.

Note: ^ is the control button

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM