Developing Rubygems with RVM and Bundler

It’s safe to say that RVM and Bundler have completely changed how I interact with my Ruby applications and gems. It’s pretty well understood how to use each by itself, I didn’t have a good idea how to use them in tandem until recently. Parts of this post are based on Derek Kastner’s great post on using Bundler.

When I grab the source for a random rubygem from github and want to run its tests or test drive it, I use RVM and Bundler to create a sandbox so I don’t pollute the gems used by other Ruby projects on my box:

  rvm use 1.9.2@ --create
  gem install bundler --pre
# Would love to see this cleaned up for bundler 1.0
# e.g. bundle install --from-gemspec
  cat > Gemfile < '.'
  bundle install

The only trick here is using Bundler’s support for gemspecs to avoid the need for a separate (and redundant) Gemfile. But Andre Arko suggests that we prefer Bundler to Jeweler and I agree with him. Jeweler should check for an existing Gemfile and defer to it for dependencies when generating the gemspec:

require 'bundler' do |s|

This means that gems should check in their gemspec into git and jeweler (or however you are generating your gemspec) should be declared as a development dependency. Do your gems pass this simple test? Any thoughts on how to make this even simpler?

3 thoughts on “Developing Rubygems with RVM and Bundler”

  1. Hey, thanks for the shout out, just found it today! I’m also working on a modified version of jeweler that takes the best parts of jeweler (bumping versions, releasing code) but relies more on bundler’s features and does away with the Rakefile-generated gemspec. It’s a side project for now, but all I have left to do is decide on a way to modify the version in the gemfile, whether it’s via regex replace or modifying ruby s-expressions via ruby_parser.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>