Repository metrics
- Stars
- (3,931 stars)
- PR merge metrics
- (Avg merge 1d 23h) (51 merged PRs in 30d)
Description
I'd like to kindly suggest a feature and discuss some ideas.
My current problem is I am using the "mail" gem, and I'd like to replace the "mime-types" gem with a more efficient, API compatible gem, say, called "mime-types-native". I have several other gems along with "mail" which all depend on "mime-types" and I'd like to replace "mime-types" project wide, i.e. in all dependencies of my project too.
Additionally, some times this problem shows up in a more limited form when people have published a gem with a very restrictively versioned dependency. For example, where they might have meant to say "> 2.2" they actually wrote "> 2.2.1". This is actually a relatively common problem, and I'll try to add some references to issues bringing this up.
This issue is related to installing a library and dependency resolution.
There are a couple of ways to address this. I'll use Arch's pacman package manager as one example.
Firstly, a pacman package has several fields: provides, conflicts and depends. These are independent of the package name. For example, there are several packages which provide java.
Here is the JRE 7 package "Gemfile": https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/java7-openjdk
Here is the JRE 8 package "Gemfile": https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/java8-openjdk
Note the lines starting with provides (there are several discrete package built from this PKGBUILD file).
Essentially, with RubyGems, the only way to require functionality is to specify the exact name of the gem.
Therefore, it's not possible to make another gem, which replaces the functionality of an existing gem, and include that as a replacement. This limitation becomes an issue when using a tool such as bundler which does dependency/version management and enforces strict rules on what can and can't be installed.
I'd like to add support, without any specific requirement on syntax, to replace a package with a different package.
I'd like to suggest some possible syntax for this:
# Idea 1: Simply ignores this gem as a dependency, then we specify another one later on:
gem "mime-types", ignore: true
gem "mime-types-native", "~> 1.0"
# Idea 2: Override this gem with different version requirements
gem "mime-types", override: "~> 3.0"
# Idea 3: Mark a gem to be replaced by another which is specified elsewhere.
gem "mime-types", provided_by: "mime-types-native"
gem "mime-types-native", "~> 1.0"
In the last case, provided_by is functionally similar to git: but of course it's not pulling the gem from git but just another gem. The ideas above are not concrete but meant to be a starting point for discussion.
I think the core problem here is the inability to specify "I depend on this specific gem" vs "I depend on someone providing this API".
I will abide by the code of conduct.