Managing Gem dependencies with Rails >= 2.0.3
This is how I manage gem dependencies for Rails applications that use Rails >= 2.0.3.
Specify the dependencies in config.rb
.
Rails::Initializer.run do |config|
# ...
config.gem 'doodle'
config.gem 'aws-s3', :lib => 'aws/s3'
config.gem 'smqueue', :version => '0.1.0'
# ...
end
Since I don't want to make my deployment depend on all the gem sources being available I tend to pull the gems into the source tree and check them in.
sudo rake gems:install
rake gems:unpack
svn add vendor/gems/*
When it's time to deploy the application remember to build the gems that have native extensions.
rake gems:build
If you've got some sort of build system in place that produces application packages then this should be done as part of building that package. If you're using Capistrano then it should be done in an after deploy:update_code
callback.
You can verify that I've written this post by following the verification instructions:
curl -LO http://barkingiguana.com/2009/01/17/managing-gem-dependencies-with-rails-203.html.orig
curl -LO http://barkingiguana.com/2009/01/17/managing-gem-dependencies-with-rails-203.html.orig.asc
gpg --verify managing-gem-dependencies-with-rails-203.html.orig{.asc,}
If you'd like to have a conversation about this post, email craig@barkingiguana.com. I don't bite.