Should I chmod gem writable directories?

I am new to Solaris and new to Ruby. When I install some gem file
using
gem install, I get this warning. I’d like to make these gems available
globally:

bash-3.00$ gem install thor
WARNING: Installing to ~/.gem since /opt/coolstack/lib/ruby/gems/1.8
and
/opt/coolstack/bin aren’t both writable.
/opt/coolstack/lib/ruby/site_ruby/1.8/rubygems/installer.rb:149:
warning: Insecure world writable dir /opt/coolstack/lib/ruby in PATH,
mode 040777

Should I just chmod 777 /opt/coolstack/lib/ruby/gems/1.8 /opt/
coolstack/bin

or should I do something else?

It doesn’t really matter and primarily depends on your execution
environment. If you sudo gem install ... it will put them in the
system gem directory, if you are installing them as a user, it will
give you that error and create a .gem directory in your home
directory. What’s important is that the gems are available to the user
that the app will run under, though if you use the environment.rb
method (typically “config.gem …”), you can install all of the gems
to that user’s environment upon deployment via rake gems:install.

At any rate, you should never have to use a mode of 777. If you think
you do, you’re likely Doing It Wrong.

-eric

Thanks, Eric, for great response. The problem with doing “sudo gem
install” is that I think env variables such as “PATH” are not passed
when you do sudo. So, gems might give some errors.

I am not familiar with environment.rb method. Could you explain or
give me a link about this? I’d like gems to be globally available to
all ruby/rails users.

Thanks.

2009/9/18 catel1 [email protected]:

Thanks, Eric, for great response. The problem with doing “sudo gem
install” is that I think env variables such as “PATH” are not passed
when you do sudo. So, gems might give some errors.

I am not familiar with environment.rb method. Could you explain or
give me a link about this? I’d like gems to be globally available to
all ruby/rails users.

I don’t know about Solaris but on Ubuntu sudo gem install is the way to
do it.

Colin

Thanks for your message. In Solaris, sudo doesn’t pass PATH info to
the command.
http://ruby-oci8.rubyforge.org/en/InstallForInstantClient.html
(scroll down to end of the page and you’ll see :
ruby-oci8 try to get the Instant Client location from library search
path.
note: If you use sudo, use it only when running ‘make install’. sudo
doesn’t pass library search path to the executing command for security
reasons

So, what should I do to make sure gems are installed and available
globally?

Also, another question: I was trying to do a rake db:migrate but I got
errors. Like this:


bash-3.00$ rake db:migrate
bash: /opt/coolstack/bin/rake: Permission denied
bash-3.00$ ls -ltr /opt/coolstack/bin/rake
-rwxr-x— 1 root root 374 Sep 16 07:17 /opt/coolstack/
bin/rake


Did the sys-admin forget to give me permission to run rake or am I
doing something wrong? And how to fix this? I am not root. I can do
sudo gem, sudo ruby. But that’s about it.

Any ideas?

Colin L. wrote:

I don’t know about Solaris but on Ubuntu sudo gem install is the way to
do it.

This is also true on Mac OS X/Darwin UNIX.

bash-3.00$ rake db:migrate
bash: /opt/coolstack/bin/rake: Permission denied
bash-3.00$ ls -ltr /opt/coolstack/bin/rake
-rwxr-x— 1 root root 374 Sep 16 07:17 /opt/coolstack/
bin/rake

I’m thinking the OP has bigger problems than the “to sudo or not to
sudo” issue. According to this output only root or members of the root
group can execute rake. That’s not going to work unless your logged in
as root, which is a bad idea, of course.

Here’s the permission for rake on Mac OS X:
-rwxr-xr-x 1 root wheel 387 May 18 16:28 rake

rake is installed in /usr/bin, since Ruby on Rails is a standard install
on Mac OS X. Notice here that only root has write permission, but anyone
can execute rake.

At any rate, you should never have to use a mode of 777.

+1 on this. 777 is a copout for lazy system admins. Server hackfest
anyone?