Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Gem::Version allows proper comparison of version strings #2810

Closed
wants to merge 1 commit into from
Closed

Gem::Version allows proper comparison of version strings #2810

wants to merge 1 commit into from

Conversation

pboling
Copy link

@pboling pboling commented Dec 22, 2020

Using Gem::Version will result in comparisons that handle pre and rc and other variations of versions properly. Also it won't result in version silliness like '2.2.10' < '2.2.2' # => true.

With string version comparison, you have to resort to whacky hacks like converting to Float (line 76), or knowing all possible variations of the comparator.

>> '2.2.10' < '2.2.2'
=> true
>> Gem::Version.new('2.2.10') < Gem::Version.new('2.2.2')
=> false

Gem::Version is also part of Rubygems proper, so it is always available (in this context)!

Version comparison will always be an ongoing issue for rspec-core as it still supports back to Ruby 1.8.7. Related: #2750

Using Gem::Version will result in comparisons that handle `pre` and `rc` and other variations of versions properly.  Also it won't result in version silliness like `2.2.10 < 2.2.2 # => true`. 

With string version comparison, you have to resort to whacky hacks like converting to Float, or knowing all possible variations of the comparator.
@JonRowe
Copy link
Member

JonRowe commented Dec 22, 2020

Thanks for contributing this, its possible to disable rubygems and we support that use case.

@JonRowe JonRowe closed this Dec 22, 2020
@JonRowe
Copy link
Member

JonRowe commented Dec 22, 2020

(The gem file also only contains these workarounds for selecting gems for CI)

@pboling
Copy link
Author

pboling commented Dec 22, 2020

@JonRowe I understand supporting RSpec running without rubygems, but it is literally impossible to support developing RSpec using a Gemfile and Bundler without Rubygems. This PR doesn't conflict with support for no-Rubygems implementations, as far as I can tell.

As you said, this file is primarily for CI, and in CI Rubygems is always in use it seems (every build passed).

If you can't use Gem::Version here then how are you able to use a Gemfile period?

@JonRowe
Copy link
Member

JonRowe commented Dec 22, 2020

Regardless its an unnecessary change for us.

@pboling
Copy link
Author

pboling commented Dec 22, 2020

Once you've been burnt by an unexpected bad version comparison result you'll sing a different tune I expect. This kind of change isn't because it is needed now. It is to set precedent that will prevent unexpected problems in the future. But the time spent on this discussion between us has already outweighed the marginal usefulness. Cheers!

@pboling pboling deleted the patch-1 branch December 22, 2020 19:27
@pirj
Copy link
Member

pirj commented Dec 22, 2020

@pboling Trust me, we have had some burning experience
It was hard to get to the root cause and a product of hard work of multiple people to fix it.

We have a lot of non-imaginary issues at the moment. If you really like to help, pick one of the tickets and send a pull request, it is always welcome.

@rspec rspec locked and limited conversation to collaborators Dec 22, 2020
@JonRowe
Copy link
Member

JonRowe commented Dec 23, 2020

These comparisons are only used to pin gems to working versions on older versions of Ruby. This is done to fix build issues as they occur so are tested by fixing the build from that point onwards.

So please accept our apologies for wanting to remain cautious and not arbitrarily change this for no benefit.
We wouldn't use anything other than standard released versions here usually.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants