"Permission denied" error when trying to install Ruby


In step 3.1 of the Installing Ruby section of Web Dev 101, I’m supposed to execute the following command in Terminal:

echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

However, when I try to do this I keep getting the following error:

-bash: /Users/aet/.bash_profile: Permission denied

Does anyone have any ideas why this could be? Thanks!


You might get this error if you are trying to “execute” .bash_profile without a command. Can you confirm whether or not you copy/pasted the command, or if you tried typing it instead?


I tried copy/pasting and typing, and I got “Permission denied” both times


You can try opening .bash_profile with a text editor and inserting eval "$(rbenv init -)" manually at the end of your file.


I tried editing it manually, but the file was locked. I fixed it using the top-level answer from this Stack Overflow thread: