strickland
strickland

Reputation: 1993

Why do I have to use sudo when installing gems

I'm a newbie when it comes to OSX and was curious if there was a setting I could enable to not force me to use sudo when installing gems.

Anyone?

Upvotes: 0

Views: 229

Answers (4)

tee
tee

Reputation: 4409

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.

Upvotes: 0

Alex Korban
Alex Korban

Reputation: 15126

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.

Upvotes: 1

John Giotta
John Giotta

Reputation: 16934

Mainly this is a security assurance, since you could be installing potentially harmful binaries, placing files in protected folders or changes to the OS.

Upvotes: 0

zigdon
zigdon

Reputation: 15063

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.

Upvotes: 3

Related Questions