So you’ve tried
sudo gem install rjb
and it just won’t work?
How about:
export JAVA_HOME='/System/Library/Frameworks/JavaVM.framework/Home' sudo gem install rjb
Still won’t work?
That’s because sudo won’t inherit the JAVA_HOME variable. Try this:
sudo su - export JAVA_HOME='/System/Library/Frameworks/JavaVM.framework/Home' gem install rjb
…now enjoy the RJB gem. :)
Managing a distributed Rails application without Capistrano is painful at best. If you have ever had to do it you know what I am talking about.
Capistrano makes things much easier. Case in point is updating your gems across multiple servers. Here is the Capistrano recipe that we use to keep gems updated:
desc "Update ruby gems"
task :update_gems, :roles => [:web, :admin, :app] do
cmd = "/usr/local/bin/gem update --include-dependencies"
sudo cmd do |channel, stream, data|
puts "#{channel[:host]}: #{data}"
if data =~ /([12])\.[^\(]+\(ruby\)/
channel.send_data "#{$1}\n"
end
end
endNow, you’ll probably need to customize it to your own needs. For instance, change the roles to suit your own setup. Also, you may want to modify the path to your ‘gem’ executable, and configure ’sudo’ to allow your user to run that command without a password. You’ll have to do that on each server as follows:
sudo visudoThen add a line like this:
myuser ALL=(ALL) NOPASSWD: /usr/local/bin/gem update --include-dependencies
If you don’t have access to ‘visudo’ ask your administrator.
Also, Win32 users will need to change the regular expression from this:
if data =~ /([12])\.[^\(]+\(ruby\)/to this:
if data =~ /([12])\.[^\(]+\(mswin32\)/… so Capistrano will choose the correct version of the gem to use.
Basically this recipe will run the ’gem update --include-dependencies’ command and analyze the output choosing the correct latest version of gem to install.
Older posts: 1 2
