Home > Uncategorized > Gem Bundler to the Rescue

Gem Bundler to the Rescue

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 http://gembundler.com 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://github.com/tenderlove/nokogiri.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.

Advertisements
Categories: Uncategorized Tags:
  1. October 12, 2011 at 1:33 am

    As one of the sysadmins that was “eliminated”, I say “bravo!” I second Joe’s assertion that this solved many problems in one fell swoop. Gem bundler has done wonders for allowing developers to develop without depending on the sysadmins to have the right version of gems installed. This is especially important when versions needed to change for a particular release. We used to spend way too much time tracking down weird gem versioning problems that we didn’t discover until they were in production.

    I go so far as to remove all system gems so that developers CAN’T be lazy and depend on system gems and then shoot themselves in the foot later by not specifying the correct version.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: