{"action":"created","issue":{"url":"https://api.github.com/repos/rubygems/rubygems/issues/1746","repository_url":"https://api.github.com/repos/rubygems/rubygems","labels_url":"https://api.github.com/repos/rubygems/rubygems/issues/1746/labels{/name}","comments_url":"https://api.github.com/repos/rubygems/rubygems/issues/1746/comments","events_url":"https://api.github.com/repos/rubygems/rubygems/issues/1746/events","html_url":"https://github.com/rubygems/rubygems/issues/1746","id":182144678,"number":1746,"title":"Feature: gem aliases/provides/replaces","user":{"login":"ioquatix","id":30030,"avatar_url":"https://avatars.githubusercontent.com/u/30030?v=3","gravatar_id":"","url":"https://api.github.com/users/ioquatix","html_url":"https://github.com/ioquatix","followers_url":"https://api.github.com/users/ioquatix/followers","following_url":"https://api.github.com/users/ioquatix/following{/other_user}","gists_url":"https://api.github.com/users/ioquatix/gists{/gist_id}","starred_url":"https://api.github.com/users/ioquatix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ioquatix/subscriptions","organizations_url":"https://api.github.com/users/ioquatix/orgs","repos_url":"https://api.github.com/users/ioquatix/repos","events_url":"https://api.github.com/users/ioquatix/events{/privacy}","received_events_url":"https://api.github.com/users/ioquatix/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rubygems/rubygems/labels/status:%20triage","name":"status: triage","color":"fef2c0"},{"url":"https://api.github.com/repos/rubygems/rubygems/labels/type:%20feature%20request","name":"type: feature request","color":"bfe5bf"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-10-11T00:16:33Z","updated_at":"2016-10-12T02:45:48Z","closed_at":null,"body":"I'd like to kindly suggest a feature and discuss some ideas.\r\n\r\nMy 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.\r\n\r\nAdditionally, 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.\r\n\r\nThis issue is related to installing a library and dependency resolution.\r\n\r\nThere are a couple of ways to address this. I'll use Arch's `pacman` package manager as one example.\r\n\r\nFirstly, 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.\r\n\r\nHere is the JRE 7 package \"Gemfile\": https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/java7-openjdk\r\n\r\nHere is the JRE 8 package \"Gemfile\": https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/java8-openjdk\r\n\r\nNote the lines starting with `provides` (there are several discrete package built from this PKGBUILD file).\r\n\r\nEssentially, with RubyGems, the only way to require functionality is to specify the exact name of the gem.\r\n\r\nTherefore, 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.\r\n\r\nI'd like to add support, without any specific requirement on syntax, to replace a package with a different package.\r\n\r\nI'd like to suggest some possible syntax for this:\r\n\r\n```\r\n# Idea 1: Simply ignores this gem as a dependency, then we specify another one later on:\r\ngem \"mime-types\", ignore: true\r\ngem \"mime-types-native\", \"~> 1.0\"\r\n\r\n# Idea 2: Override this gem with different version requirements\r\ngem \"mime-types\", override: \"~> 3.0\"\r\n\r\n# Idea 3: Mark a gem to be replaced by another which is specified elsewhere.\r\ngem \"mime-types\", provided_by: \"mime-types-native\"\r\ngem \"mime-types-native\", \"~> 1.0\"\r\n```\r\n\r\nIn 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.\r\n\r\nI think the core problem here is the inability to specify \"I depend on this specific gem\" vs \"I depend on someone providing this API\".\r\n\r\nI will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).\r\n"},"comment":{"url":"https://api.github.com/repos/rubygems/rubygems/issues/comments/253104458","html_url":"https://github.com/rubygems/rubygems/issues/1746#issuecomment-253104458","issue_url":"https://api.github.com/repos/rubygems/rubygems/issues/1746","id":253104458,"user":{"login":"duckinator","id":39698,"avatar_url":"https://avatars.githubusercontent.com/u/39698?v=3","gravatar_id":"","url":"https://api.github.com/users/duckinator","html_url":"https://github.com/duckinator","followers_url":"https://api.github.com/users/duckinator/followers","following_url":"https://api.github.com/users/duckinator/following{/other_user}","gists_url":"https://api.github.com/users/duckinator/gists{/gist_id}","starred_url":"https://api.github.com/users/duckinator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckinator/subscriptions","organizations_url":"https://api.github.com/users/duckinator/orgs","repos_url":"https://api.github.com/users/duckinator/repos","events_url":"https://api.github.com/users/duckinator/events{/privacy}","received_events_url":"https://api.github.com/users/duckinator/received_events","type":"User","site_admin":false},"created_at":"2016-10-12T02:45:47Z","updated_at":"2016-10-12T02:45:47Z","body":"Also:\r\n\r\nAn alternative syntax could be:\r\n\r\n```ruby\r\ngem \"mime-types-native\", \"~> 1.0\", provides: \"mime-types\"\r\n```\r\n\r\nAnd I just noticed a potential issue: How do you specify what *version* a gem is equivalent to?\r\n\r\nE.g., say version 1.0 of mime-types-native is API-compatible with version 3.0 of mime-types. I've seen this kind of thing before, and it'd need to be handled.\r\n\r\nAnd having both the version and `provides:` is already messy. Adding a second version could get very confusing.\r\n\r\nExtending my alternative syntax above, perhaps something like,\r\n\r\n```ruby\r\ngem \"mime-types-native\", \"~> 1.0\" do\r\n  provides \"mime-types\", \"~> 3.0\"\r\nend\r\n```"}}
{"actor":{"display_login":"duckinator"}}