Ruby Installing a Ruby Development Environment Installing a Ruby Development Environment Installing Ruby on Mac

write permissions for gem install bundler

I've just started installing ruby on rails. Everything in the setup was going fine until I tried to install the Gems. I received this error

ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

any help would greatly be appreciated

4 Answers

Thomas Anthony
Thomas Anthony
iOS Development Techdegree Student 22,352 Points

You need to specify the sudo command before you gem install because you do not have write permissions for the /Library/Ruby/Gems/2.0.0 directory. sudo is a shell command that gives you elevated privileges and allows you to perform system-level operations without switching to the root user. Be very cautious, however. Make certain you double check your commands before execution. It is very easy to perform a command that could potentially cause irreversible damage i.e. sudo rm -rf / (NEVER DO THIS!!!).

Make note, you will have to use the sudo command each time you gem install unless you perform some rather advanced account configurations.

Charles Franklin
Charles Franklin
17,535 Points

Thanks for this.. I ran into the same problem..

Eric Tirado
PRO
Eric Tirado
Pro Student 6,966 Points

I still get an "Operation not permitted" when using "sudo gem install bundler" Here's a screenshot

Eric Tirado
Eric Tirado
Pro Student 6,966 Points

I was using OSX 10.10 and just updated to 10.11 beta. Still have the same issue.

Thomas Anthony
Thomas Anthony
iOS Development Techdegree Student 22,352 Points

It is just as I suspected. Some users that migrated to the beta release of El Capitan have reported their system running "rootless". You may solve this problem if you set the firmware nvram variable boot-args to "rootless=0". Simply run this set of commands: sudo nvram boot-args="rootless=0"; sudo reboot. When your system reboot completes, try running sudo gem install bundler again. Let me know if this information solved your problem. Good luck.

Daniel Peñaloza
Daniel Peñaloza
3,292 Points

Have the same problem. Copy the set of commands and the terminal answer :"syntax error near unexpected token `;;' " Any idea what can i do?

Thomas Anthony
Thomas Anthony
iOS Development Techdegree Student 22,352 Points

It seems as though the markdown interpreter HTML-escaped the " characters within the back-ticks. At the time of writing, this was not an issue (I suppose it interprets the code as HTML by default). I have updated my answer to account for this. You should be able to copy and paste the command as-is.