jasonpgignac
jasonpgignac

Reputation: 2306

Gem and bundler: Adding a development dependency with a relative path

I'm helping on the development of a series of interrelated gems. As such, I don't want them to have a hard dependency on each other, but I do want them to run tests in development that use each other. Simple right? Just use add_development_dependency in the gemspec, right? Well, there is one little wrinkle - the git repository contains all the gems, and so I want the Gemfile to point to the local copy of the gem. This works with a hard dependency. In the gemspec, I have this line for my hard dependency:

s.add_dependency "mygem-core"

And then in the Gemfile, I have this line:

gem "mygem-core", :path => "../mygem-core"

This works PERFECT. The dependency exists for when I push this package out, and when I'm testing, it will use the local copy of mygem-core. The problem is that when I put THIS in the gemspec:

s.add_development_dependency "mygem-runtime"

And then this in the Gemfile:

gem "mygem-runtime", :path => "../mygem-runtime"

Then I get an error when I run bundle:

You cannot specify the same gem twice coming from different sources. You specified that mygem-packager (>= 0) should come from source at ../mygem-packager and 

Yes, that's not a typo at the end. There is literally a blank, empty space at the end for the second 'location'. Is there any smart ways to work around this? I want to add this as a development dependency, and use the local source. What am I missing?

Upvotes: 20

Views: 8091

Answers (2)

Kris
Kris

Reputation: 19958

If your using Gemfile to specificy a local path to a gem you will need to remove it from gemspec. Bundler will parse gemspec and add the dependencies those bundler is installing, so its like having the gem specified twice.

Upvotes: 1

Rico Sta. Cruz
Rico Sta. Cruz

Reputation: 546

It's probably better that you leave that gem out of the .gemspec manifest and put it in the Gemfile under the :development group.

# Gemfile
source :rubygems
gemspec

gem "mygem-runtime", :path => '../mygem-runtime', :group => :development

Upvotes: 11

Related Questions