I'm a newbie when it comes to OSX and was curi开发者_开发知识库ous if there was a setting I could enable to not force me to use sudo when installing gems.
Anyone?
You need to use sudo because you're installing the libraries to the system area, by default, which is not writable by non-privileged users.
I don't know offhand if there's a way to get gems to install to a user library, but assuming they learned from perl's CPAN, it seems likely that that is possible.
On Linux at least (and I think OSX is the same), you don't have to use sudo to install gems. If you don't, they are installed into your home folder. If you do, they are installed into a location that isn't writeable without sudo.
Try running gem env
and sudo gem env
and comparing the output. You will see that the installation directory and gem paths are different.
Use RVM to manage your ruby installs, multiple ruby versions, and gems for different ruby versions and projects. Then you will not need sudo to install gems and a lot of other things will be easier too.
Mainly this is a security assurance, since you could be installing potentially harmful binaries, placing files in protected folders or changes to the OS.
精彩评论