Rubygems: Support blacklisting certain dependency versions

Created on 25 Feb 2019  路  4Comments  路  Source: rubygems/rubygems

(moved from Ruby -> CommonRuby issue tracker)

Abstract

This feature request proposes introducing a new dependency constraint !=, which will allow to blacklist a specific buggy version of some gem dependency without dropping support for older releases.

Background

I am developing a gem which extends functionality of the Mail gem. It works with Mail 2.6.4 onwards (the current latest is 2.7.1), therefore I'd normally define a dependency constraint as combination of ~> 2.6 AND >= 2.6.4.

However, there is one exception: Mail version 2.7.0 has some bug, which is fatal for my gem. This bug has been fixed in 2.7.1. I need to prevent users from using the buggy version of Mail with my gem. Currently, I can do following:

  1. Bump version constraint on Mail gem to ~> 2.7 AND >= 2.7.1.

  2. Release two separate gems (or versions), one with constraint ~> 2.6.4, and another with ~> 2.7 AND >= 2.7.1.

  3. Display a proper message in README and post-install step in order to inform users that they should care about Mail version themselves (e.g. constrain it in their gemfiles).

  4. Perform a runtime check, and raise exception on incompatible Mail version.

  5. Any reasonable combination of above.

Option 1 seems to be the best. It is easy and very straightforward, also it does not break Bundler's gem resolution. However, it seems wrong to remove support for older versions only because single version of Mail is buggy. What is more, such change to dependencies may be considered as a breaking one. Option 2 adds an unnecessary maintenance burden, and feels odd in general. Options 3 and 4 are also quite odd, as they seem to be an unnecessary complication, and may surprise users who have just upgraded my gem.

Actually, what I would really want to achieve is to be able to define dependency constraint as ~> 2.6 AND >= 2.6.4 BUT NOT = 2.7.0.

Proposal

For this reason, I propose introducing != version constraints, which exclude unwanted versions explicitly. For example, in my case I should be able to write ~> 2.6 AND >= 2.6.4 AND != 2.7.0.

feature request

Most helpful comment

This is already possible. gem 'mail', '!= 2.7.0' just works.

All 4 comments

This is already possible. gem 'mail', '!= 2.7.0' just works.

How embarrassing. I've searched documentation for it without luck, but I haven't experimented. Yes, it suits my needs perfectly. Thanks a lot!

Nevertheless, I believe this feature could be better documented. There is a section Guides -> Patterns -> Declaring Dependencies, which informs about ~>. I suppose a word or two about != could be added. (I could do it myself, but my English is far from perfect, I would need a a proof reader at least.)

Please, go ahead and make a PR! I agree the docs can be improved. :+1:

Nevertheless, I believe this feature could be better documented. There is a section Guides -> Patterns -> Declaring Dependencies, which informs about ~>. I suppose a word or two about != could be added. (I could do it myself, but my English is far from perfect, I would need a a proof reader at least.)

please open a new issue about it or PR, thanks :) i'm going to close this issue since is solved now

Was this page helpful?
0 / 5 - 0 ratings