简体   繁体   中英

How to fix gem permission error after installing rbenv?

I was trying to install Sinatra and I kept on getting this error: You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory

Thanks to " Installing gem or updating RubyGems fails with permissions error " I installed rbenv. I followed the guide and set my global ruby version, etc. but I continue to get the same error when I try to install gems. When I run gem environment the installation directory for RubyGems is still the system Ruby directory.

Should I update GEM_PATH? Since the rbenv guide doesn't mention anything about that, something makes me think that there is still a problem with my rbenv installation.

Can someone please help me figure this out?

You're not showing us the commands you're using but it smells like you're using sudo to install Sinatra. Don't do that with rbenv or RVM managed Rubies.

Just as in the linked question , using rbenv or RVM allows you have one or more Rubies in your user-space where you can modify them all you want. That means you don't need to use sudo , just use gem install ... .

An alternate problem you could be having is you set your global Ruby to be system , which is the version installed by Apple for their use, and which you don't want to modify unless you understand why it's there and what they're using it for. IF you have to change it then sudo would be appropriate but, with rbenv or RVM managing Rubies in your user-space there's really no reason to.

Do NOT use chmod to change the ownership of the vendor installed gems; Again, that's for Apple's use so have fun with the local Rubies instead and leave Apple's alone.

In this case, I quit Terminal and upon reopening, things were working correctly. Probably a good thing to try if you're stuck and are sure you've followed instructions correctly. It's not explicitly mentioned in the material I read but I believe is a good practice in general.

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