Gemfile vs .gemspec for dev dependencies in a Gem/Engine

I can’t seem to find any clarification on this online -

Is there a reason why someone would declare development dependencies in their .gemspec file vs their Gemfile (with bundle groups). Or why both forms would be used in the same project?

Examples:

1 Like

When I need to clarify these concepts I always go to this in-depth article from Yehuda Katz: Clarifying the Roles of the .gemspec and Gemfile

I hope it’s helpful to you!

I hope it’s helpful to you!

I’m sorry, but it really isn’t. It would be helpful to cite relevant parts here. (I don’t know what that site and its purpose is, but Google gives this address at the top as the answer to the question in the title.)

The main differeence I’ve seen is when doing a gem install mygem. Relevant information is here:

All dependencies from the gemspec and Gemfile will be installed by bundle install, but rspec and rubocop will not be included by gem install mygem or bundle add mygem.

from https://bundler.io/rubygems.html

gem install mygem will not install development dependencies of the gem, e.g. add_runtime_dependency vs add_development_dependency