It seems every time I want to install something locally on Snow Leopard, I run into an issue about whether to install to /usr/local or whether or not to run install commands using sudo. I’ve read conflicting advice on this, including on stackoverflow
Gem install errors writable and PATH (use sudo)
gem install permission problem (do not use sudo in comments)
Should I be installing brew formula and gems using sudo? How can I avoid errors and warnings when I install without sudo privileges?
e.g when running gem update:
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /Users/luke/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
I’m not a ruby developer but want to use sass and compass, so it seems like overkill to install rvm. Will just adding ruby to my path resolve all these issues? I also saw somewhere that I should chown /usr/local. It would be good to finally get to the bottom of this.
I prefer to use
sudo, so I am sure that programs running with normal privileges can’t mess with system-wide files. I also normally run as a non-administrator user for the same reason. This means that I am protected from damaging the system even accidentally, but when I decide to install something to/usr/localI have to usesudo, so I only do that when I’m sure that it won’t make a mess. For stuff that I’m not sure about, or that I simply want to try, etc., I install to a prefix in my home.Other people have a more single-user mentality, and chown
/usr/localto themselves. They’re ok with the risk of messing up its contents with normal usage: for instance, if they try to install something to a prefix in their home, but the configure is borked, it could install some pieces in/usr/localwithout so much as a warning. OTOH, when they install to/usr/localthey are sure that they won’t affect the rest of the system, only/usr/localand their own home.But then,
/usr/localis just an extension of their home directory, since it has the same ownership and the same privileges. They might as well install to~/usr/and add~/usr/binto their PATH, which is what I do when I want to install things for myself.The very best way would probably be to chgrp
/usr/localto some special group, andsudoto a special user in that group that can write to that directory, but not do other random sudo stuff. Maybe someday I’ll get around to configuring it that way. In the meantime, I prefer to usesudowhen I want to install to/usr/local. The advantage of using a package manager like homebrew is that formulas have been checked to ensure that they install cleanly, and they can easily be uninstalled.