Insecure world writable dir /usr/local in PATH when trying to install Rails 3.0.3

I am trying to install rails 3.0.3 and i get the following error every time:

Insecure world writable dir /usr/local in PATH, mode 040777

When I check to see if it installed I get this error:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:827:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:261:in `activate'
 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:68:in `gem'
 from /usr/bin/rails:18

Any idea what I am doing wrong? Sorry, I'm a newb!


Solution 1:

You need to secure that directory before the install. Use:

chmod o-w /usr/local

to do this. If that doesn't work, the you probably need to be root (or otherwise suitably empowered) so you can try:

sudo chmod o-w /usr/local

and enter your password.

I've seen this sort of thing before on some software which really wants things set up in a certain way to ensure that its assumptions are met. In any case, it's actually a bad idea to have world writable directories except when you know security on them is not a big deal.

/usr/local is important enough that you shouldn't allow anyone to write to it.

Solution 2:

For osx it's: sudo chmod -R o-w /usr/local