Question

I have a gem A which has a dependency on gem B. Both gems are my own and are currently in private development. I have no plans to publish these to rubygems.

I want to use gem A in my rails app.

The problem is I'm getting this error when I try to run bundle install for my rails app.

Could not find gem 'B (>= 0) ruby', which is required by gem 'A (>= 0) ruby', in any of the sources.

in my rails app in my Gemfile i have

gem 'A', :path => "/path/to/A'

in gem A's gemspec I have

gem.add_dependency 'B'

and in A's Gemfile I explicity set B's location like so

gem 'omusubi', :path => "path/to/B'

The above configuration doesnt seem to be working when I try to run my rails app.

However when I run each of the gem's test suites they pass fine.

I believe the problem is when I run the rails app and bundler loads the dependency A, it only looks at the A's gemspec ignoring the gemfile altogether. This is probably intended. So how do I get my code to work without having to commit to publishing my private gems during this development stage.

Was it helpful?

Solution

One possibility is to put a hard dependency on B in your app's Gemfile, using the :path option. Bundler should resolve it correctly in this case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top