pgn
pgn

Reputation: 679

Have Bundler parse and load dependencies from Gemfile/s in gem/s loaded with :path

here's my current situation:

I am working on a rails engine ( "awesome_engine" ). I do all development via a host application, i.e. a rails app that specifies this engine as a dependency in its Gemfile with the :path parameter

    gem "awesome_engine", :path => "awesome_engine"

This works well- the engine gem folder is under "awesome_engine" relative to the root of the host application. However "awesome_engine" references a gem that is also in development, "awesome_core". awesome_engine/Gemfile therefore reads:

    gem "awesome_common", :path => "../awesome_core"

THe problem with this setup seems to be that Bundler does not look for a Gemfile in awesome_engine/ when it creates the application bundle for the host rails application, it only reads dependencies from the gemspec of "awesome_engine", which is fine for any single gem you'd want to have loaded in its "unpackaged" state, not so great for when you want to work on a graph of related gems at the same time

Am i

a) trying to bite off more than i can chew and should just dump "awesome_core" in the Gemfile of the host app while it is under development and be happy with it ( i won't be :-) )

b) missing something trivial on how to have Bundler do this

c) none of the above ( please specify: ________ )

thanks! Andras

ps: i know Bundler does not parse "awesome_engine/Gemfile" because a) if i put crap in it bundle install in the host app still runs fine b) none of the other dependencies from that file end up in the host applications app bundle

Upvotes: 2

Views: 497

Answers (1)

moritz
moritz

Reputation: 25757

So when you specify a gem through your (current project's) Gemfile, it is assumed that you are referencing something with well defined dependencies. This means that it is expected that there is a valid .gemspec file that names those dependencies. But this you already know.

My suggestion for c) would be to create your gems with bundle gem which sets up the gem in a way that information for it's Gemfile is drawn from the .gemspec file. Have a look at http://gembundler.com/v1.2/bundle_gem.html and just generate a test gem and read its sources, it's quite clear.

I hope that solves your problem.

Upvotes: 1

Related Questions