0

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)?

1
  • Can I bring this back to my ownership or shared?
    – Kerry7777
    Commented Aug 14, 2018 at 10:48

2 Answers 2

0

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.

3
  • I still get the same message when using sudo: -bash: /Users/macbookpro/.bash_profile: Permission denied
    – Kerry7777
    Commented Aug 14, 2018 at 10:51
  • You could try changing the ownership to your user: chown $(id -u -n) ~/.bash_profile, or if that won't work try:sudo chown $(id -u -n) ~/.bash_profile
    – l'L'l
    Commented Aug 14, 2018 at 10:53
  • 1
    Your very last comment helped. Thanks.
    – Kerry7777
    Commented Aug 14, 2018 at 11:12
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.