Sean Mackesey
Sean Mackesey

Reputation: 10949

How to make Bundler recognize location declarations of indirect dependencies?

I am working on a small team and have developed several gems for internal use. These gems are variously interdependent and are hosted on my Github account. When I declare dependencies on these gems, I always put in the declaring Gemfile: :git => 'url/for/gem/on/github'. But I am running into some confusing behavior from Bundler-- I would think that:

But Bundler complains that it can't find C. If I declare C in A's Gemfile with the proper location, then it does not complain. Am I right in inferring that Bundler does not actually look at dependency Gemfiles at all, and rather just looks at their gemspec? And if I am, is there a better solution to the problem I describe than declaring C as a dependency of A directly in A's Gemfile?

UPDATE: It seems that if you could declare a Github account as a gem source in the Gemfile, then this problem would be solved. Is this possible?

Upvotes: 3

Views: 163

Answers (1)

We recently had to tackle a very similar situation with internal gems depending on each other. We already used an internal git host (GitLab) but had the same problems with not being able to declare bundle style git:and branch: attributes in the gemspec.

The solution for us was to set up internal gem hosting as well. Using geminabox it's really easy to get a gem host up and running. run gem install geminabox and create a folder for your web service (we use passenger, ymmw):

gems/
  public/
  tmp/
    restart.txt
  gems/
  config.ru

The edit config.ru so something like this:

require "rubygems"
require "geminabox"

Geminabox.data = "gems"
run Geminabox

And point passenger at the gems/public folder and it'll start up as a normal rack app for you to play with. Simply add the url to the service in the gemfiles and skip the whole git problem for internal gems, that's my advice :)

More info on geminabox can be found on their github page: https://github.com/geminabox/geminabox

Upvotes: 2

Related Questions