A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rubygems/rubygems/issues/7799 below:

unclear on which one to use · Issue #7799 · rubygems/rubygems · GitHub

Reference: rubygems/guides#370

Problem

When adding a non-development dependency to a gemspec, it can be unclear what to use between add_dependency and add_runtime_dependency.

Let me elaborate by doing a comparison across different places.

In the docs and generators In the wild In the code Interpretation

I don't know if there was a conscious push for either add_dependency or add_runtime_dependency, or if both just happened organically. It seems to me that the latter case is what happened, but maybe someone who is more well versed into rubygems can shed more light on the matter.

The current state of affairs seems to be that add_dependency is the more popular way in terms of usage, and the Bundler guide and bundler gem code generation suggestion only mention this way.

Possible solutions

@deivid-rodriguez mentioned some possible solutions here. Here is is a non-exhaustive list with my suggestions as well:

  1. Edit the specification reference to show separate entries for aliases. Maybe by making them look as important as non-aliased methods like this:

    This is similar to what the Rails API does for example here.

  2. Or invert so that add_dependency becomes the main method, and add_runtime_dependency the alias, which would look like this:

  3. Or use add_runtime_dependency in the bundle gem generated gemspec and maybe use add_runtime_dependency in the Bundler guide

  4. Maybe this is a non-issue and there is no main way to go, and it all depends on what context you're in. add_development_dependency could be considered a nice symmetrical counterpoint to add_runtime_dependency when using both in the same gemspec.

    If using the Gemfile for development dependencies and gemspec for non-development dependencies, which is what currently happens when doing bundle gem, then the way it is currently done (i.e. suggesting add_dependency in the generated gemspec) can make more sense, as in the gemspec there wouldn't be any development dependency to be a counterpoint to.

    If no way is more preferable than the other, then we can just close this issue. One would just use what feels right depending on the context or their personal preferences. Although I would argue that doing something like solution 1 could still be useful to feature add_dependency on a more equal footing as add_runtime_dependency.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4