Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gemspec: How can I specify dependencies which don't have to be auto-required?

Tags:

I wrote a gem with a certain array of dependencies, and some of them I'd like not to have implicitly required when bundled into another project. An example is the uuidtools gem, which I only want to require in files using it.

gem.add_dependency("uuidtools",["=2.1.3"], :require => false)

This syntax is false, since :require => false is unexpected there, but this more or less sums up what I would like to do with it. Can someone help me on this?

like image 220
ChuckE Avatar asked Oct 09 '12 07:10

ChuckE


1 Answers

Gems specified in an engines gemspec file already do need to be explicitly required, by default. From the official documentation - Note that if you want to immediately require dependencies when the engine is required, you should require them before the engine's initialization. In your case, you should be able to get by with something like gem.add_dependency 'uuidtools', '2.1.3' in your gemspec file, and requires in the relevant locations.

like image 158
Brad Werth Avatar answered Sep 18 '22 03:09

Brad Werth