How to use a personal gem built on top of a gem when creating another gem
1 answer
So it took me a while to figure it out, because the answer is: it's in two places. Do it:
- In your Gem Gemfile (yes Gemfile, not .gemspec) add the source line for your private server gem. If you also pull out RubyGems then it will look something like this:
source 'http://rubygems.org'
source 'http://myrubygems.mycompany.example.com:8808' # Or wherever your gems are hosted internally (or externally)
gemspec
- Then in mynewgem.gemspec enter the following:
Gem::Specification.new do |gem|
# [...]
gem.add_dependency 'myoldgem' # the gem hosted at myrubygems.mycompany.example.com:8808
end
The reason this works is obviously obvious: your Gemfile specifies the origin for your gems, and your .gemspec specifies the dependencies.
Hope this saves someone a few minutes.
+5
source to share