Developer dependencies in RubyGems 1.2.0 using add_development_dependency

As the release note says, RubyGems 1.2.0 now supports two levels of gem dependencies, runtime and developer. If you don’t use add_development_dependency to specify a dependency, RubyGems treats it as a runtime dep.

Google, in its questionable wisdom, tells me that there’s not much interest in this feature. Echoe is already using it, which is simultaneously unsurprising and reassuring.

Perhaps I shouldn’t find the lack of widespread acclaim strange. I suppose Ruby developers don’t hack other people’s code, they just use it. GitHub will change this, perhaps already is changing this. Case in point: I cloned a project today just to see how it works, with no intention of actually using it. The project’s tests failed because I didn’t have three dependencies: one runtime, two developer.

Super. Let’s add some RubyGems 1.2.0 typed dependencies (17 Awesome Points go to anyone who can figure out the project based on this snippet).

  spec = do |s|
    s.add_runtime_dependency 'right_aws'
    s.add_development_dependency 'Shoulda'
    s.add_development_dependency 'mocha'

Now, build the gem using whatever means have been provided, and install it with its developer dependencies.

… Wait, what? The release announcement doesn’t tell me how to do trigger the developer dependencies. Google is no help, either. And good luck finding RDocs for RubyGems.

After I started grumbling, but before diving into the rubygems source, I remembered to run gem help install. There I found this beautiful, kissable tip:

 --development                Install any additional development

Here’s the information you came for: To install a gem with developer dependencies, use gem install --development

Developer dependencies should also be useful with a rake setup task, as Assaf Arkin advises having for all public projects. Somebody’s going to have to dive into the source code to figure out how to make that work.

So now I have added some niceness to a project I cloned from GitHub. It’s not much more work to fork the project, commit my changes, and shoot off a pull request. All for a project I’m not really going to use. Long live GitHub.

Leave a comment


  1. Tom

     /  July 2, 2008

    I was having the following error running a rake task after I had updated my gems:undefined method add_development_dependencyI updated gem with:sudo gem update –systemEverything seems to be working properly now.

  2. Elia

     /  September 17, 2008

    It seems that older rubygems versions (e.g. 1.1.0) will read the development dependencies as normal dependencies, i.e. runtime.That’s a problem, I suppose that before version 1.2.0 dev deps were NOT declared as dependencies, so the same should be with 1.2.0.

  3. raphaels

     /  October 18, 2008

    And what exactly are you doing cloning RightScale’s Amazon EC2 API gem? (I want my 17 points :P)

  4. Matthew King

     /  October 20, 2008

    raphaels, it was actually Paperclip, but for coming up with any project, you get 15 APs.

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: