Search code examples
bashmacosterminalrbenv

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: Permission denied

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

You don't own the file ".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)?


Solution

  • 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.