I have created a gem(X) and it's not published. Now I am creating an another gem which will add the gem X as a dependency like this :-
s.add_dependency "X"
in gemspec file.
since the gem(X) is not on rubygem or git or rubyforge, the bundle install command throws the error:
could not find the gem X**
I think specifying the path for X will do the trick, but how?
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"
gemspec
gem "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 error
gem "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.