Archive for August, 2011

Gem Bundler to the Rescue

August 12, 2011 1 comment

About 6 months ago we converted all of our Ruby applications (Rails and non-rails) to utilize Gem Bundler : “The best way to manage your application’s dependencies”

This immediately did 3 things for us:

  1. Removed our sysadmins from the picture. No more bothering them to install or update gems.
  2. Removed conflicts at the system level. We are no longer fighting with multiple installed versions of the same gem.
  3. All dependencies are documented right along side the code.
You can visit for the details but I’ll comment on a few things we do often.

By default bundler installs gems to the default system location (needing root access), to install to an alternate location use the –path argument.

$ bundle install ––path=vendor

Once installed Bundler will remember this location (.bundle/config) and you just need to run bundle install whenever your Gemfile changes.

Want to use gems that aren’t available from rubygems?  We do.  If it’s stored in git and has a .gemspec at its root you can specify the URL and bundler will install the gem directly from the source.

gem “nokogiri”, :git => “git://”

Creating Gems

Use bundler to get a quick start on your own gem. Bundler will create the basic layout with all the necessary files and even initialize it as a git repository.  Just ‘git add remote’ and push.  You can now reference your new gem in the Gemfile as shown above.

jheth@server:~$ bundle gem example
      create  example/Gemfile
      create  example/Rakefile
      create  example/.gitignore
      create  example/example.gemspec
      create  example/lib/example.rb
      create  example/lib/example/version.rb
Initializating git repo in /home/jheth/example

I use Bundler for every Ruby project I work on.  Deployments are a breeze and I can be confident my code will work wherever it goes.

Categories: Uncategorized Tags: