how to specify path for dependent gem in gemspec file? how to specify path for dependent gem in gemspec file? ruby-on-rails ruby-on-rails

how to specify path for dependent gem in gemspec file?


I think I see what @bor1s was pointing to in the SO post about git references.

The gemspec file is about dependencies for publishing your gem. Your Gemfile sets up your local environment for development, usually by calling gemspec.

In your case your gemspec should have this

s.add_dependency "X"

And then your Gemfile would look something like this (make sure the local reference is after the gemspec call):

source "http://www.rubygems.org"gemspecgem "X", :path => "/Users/vikram/source/X"

Quoting from Yahuda Katz's blog post about gemspec and Bundler

If you find that you need to develop against a gem that hasn’t yet been released (for instance, Rails often develops against unreleased Rack, Arel, or Mail gems), you can add individual lines in the Gemfile that tell bundler where to find the gems. It will still use the dependencies listed in the .gemspec for dependency resolution, but it now knows exactly where to find the dependency during gem development.

source "http://www.rubygems.org"gemspec# if the .gemspec in this git repo doesn't match the version required by this# gem's .gemspec, bundler will print an errorgem "rack", :git => "git://github.com/rack/rack.git"

You wouldn’t want to include this information in the .gemspec, which will eventually be released to Rubygems after the in-development gem has also been released. Again, this makes the overall system more resilient, as it doesn’t depend on transient external URLs. This information is purely something used to set up a complete environment during development, which requires some precision.


I think you can find an answer for your question here:Gem dependency

Hope it will help.