Feature proposal: ability to declare all dependencies in Gemfile, not in gemspec #7869
Replies: 2 comments 2 replies
-
The main reason is historical! For a long time, Bundler was not able to make changes to RubyGems itself, and had to be an additive layer on top. In that situation, gem dependencies had to live exclusively in the gemspec where RubyGems could find them. Today, it seems like this would be pretty doable! I'd be open to a PR adding this functionality. |
Beta Was this translation helpful? Give feedback.
-
I don't like this idea spreading runtime dependencies across multiple files. You should do the opposite way, specify runtime deps in gemspec and use |
Beta Was this translation helpful? Give feedback.
-
In a non-gem Rails app, all the dependencies are declared in the Gemfile. Nice and tidy.
But in a gem, dependencies nowadays are often declared in 2 different files at the same time:
Gemfile
for dev dependencies, andmy_gem.gemspec
for runtime dependencies.Wouldn't it be nice if all of a gem's dependencies could be declared in the Gemfile? Or is this a crazy idea?
I don't often create new gems but when I do, I wish I could declare all of my dependencies in the Gemfile. Gemfiles are nice. I like them. Declaring dependencies in them feels less clunky than in a gemspec.
Gemfiles can call a
gemspec
method to add dependencies from the gemspec, among other things.Conversely, why can't gemspecs call a
gemfile
(or similar) method to add dependencies from the Gemfile?It could look something like this:
or maybe just
or if you want to include specific Bundler groups:
This would be optional behavior and wouldn't break anything. Here is a hacky but working proof of concept: gist.
Would anyone find this useful, or is it just me?
Beta Was this translation helpful? Give feedback.
All reactions