Alex Smolov
Alex Smolov

Reputation: 1861

Gemfile dependencies in Rails

In a Rails application, if one of the gems included in a Gemfile depends on another one that I want to use, do I need to include the second one in a Gemfile?

Say, I use a cucumber-rails gem. By running bundle dependency cucumber-rails, I can see that it depends on 'database_cleaner' and factory_girl. Do I need to include the former two into the Gemfile or not?

Thanks!

Upvotes: 3

Views: 684

Answers (3)

Atomfinger
Atomfinger

Reputation: 714

I had a look around and apparently you should not use the bundle dependency cucumber-rails install function:

https://makandracards.com/makandra/12741-don-t-update-gems-with-bundle-update-unless-you-re-feeling-lucky

Upvotes: 1

juliehache
juliehache

Reputation: 111

No, you don't need to explicitly require them in your Gemfile. Bundler will detect the dependencies, include them in your Gemfile.lock and install them.

Upvotes: 3

Nick Ginanto
Nick Ginanto

Reputation: 32120

If you use bundler then it will install any dependency when you install a gem

you can see the dependencies in gemfile.lock

but note that having a dependency installed is not always good to assume that the dependency installed is the gem version you want. The dependency installed is the version required for the gem to work. If you need factory-girl on the latest version (or any other version), then it is best to include it in the gemfile

Upvotes: 2

Related Questions