Skip to content

Minimum Ruby version is incompatible with current code #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
danielparks opened this issue Sep 23, 2022 · 11 comments
Closed

Minimum Ruby version is incompatible with current code #301

danielparks opened this issue Sep 23, 2022 · 11 comments
Assignees
Labels

Comments

@danielparks
Copy link
Contributor

danielparks commented Sep 23, 2022

Describe the Bug

puppet-strings.gemspec reports that the minimum version of Ruby supported is 2.3.0, but there is unsupported code (match?) since at least 08936f9.

There are also a bunch of unsupported dependency problems, but that can be solved with the brute force addition of a lot of version constraints.

Switching to ruby 2.6.0p0 makes the code work fine without problems.

Expected Behavior

You should be able to install dependencies and run unit tests with the minimum ruby version.

Steps to Reproduce

Steps to reproduce the behavior:

  1. rbenv install 2.3.0 && rbenv local 2.3.0
  2. gem install bundler:1.13.7 (later versions may work)
  3. bundle install --path .bundle/gems (this will fail)
  4. Add a bunch of version constraints to Gemfile.
  5. bundle install --path .bundle/gems
  6. bundle exec rake spec
. . .
      RuntimeError:
        Processing (stdin):13 with . . . => undefined method `match?' for /ruby4x/:Regexp
. . .

Environment

  • ruby 2.3.0p0
  • macOS 12.6.0
  • Current main branch (dba16ed)
@danielparks danielparks changed the title Minimum Ruby version is incompatible with minitest Minimum Ruby version is incompatible code Sep 26, 2022
@danielparks danielparks changed the title Minimum Ruby version is incompatible code Minimum Ruby version is incompatible with current code Sep 26, 2022
@danielparks
Copy link
Contributor Author

I updated this to better reflect reality. I’m not sure what the implications of updating the minimum version would be.

I can prep a PR to fix all the errors with Ruby 2.3.0, but it involves specifying a bunch of additional dependencies with version information. It will eventually break as dependencies stop supporting 2.3.0, which will require additional constraints to be added, but that’s unavoidable with any Ruby version (perhaps unless Gemfile.lock gets added, though I don’t think that’s supported by bundler with Ruby 2.3.0).

@danielparks
Copy link
Contributor Author

To give you an idea of the number of dependencies that need to be modified: main...danielparks:puppet-strings:fix_ruby_2.3.0

I only made very minimal effort to specify them in the correct section; it’s not ready to be a PR.

danielparks added a commit to danielparks/puppet-strings that referenced this issue Sep 26, 2022
In 08936f9 ("(MAINT) Rubocop: Fix
Performance/RegexpMatch"), a few Regexp matches were switched from `=~`
to `.match?`. Unfortuantely, `.match?` [wasn’t introduced until Ruby
2.4.6][match?], so that broke Ruby 2.3.0 compatibility.

This reverts that commit and disables the relevant rubocop check.

[match?]: https://apidock.com/ruby/String/match%3F
danielparks added a commit to danielparks/puppet-strings that referenced this issue Sep 26, 2022
In 08936f9 ("(MAINT) Rubocop: Fix
Performance/RegexpMatch"), a few Regexp matches were switched from `=~`
to `.match?`. Unfortuantely, `.match?` [wasn’t introduced until Ruby
2.4.6][match?], so that broke Ruby 2.3.0 compatibility.

This reverts that commit and disables the relevant rubocop check.

[match?]: https://apidock.com/ruby/String/match%3F
@chelnak
Copy link
Contributor

chelnak commented Sep 26, 2022

@danielparks I think it's reasonable to bump the minimum version. I'll discuss internally too just incase anyone can see an issue with it.

@danielparks
Copy link
Contributor Author

Cool! That seems a lot cleaner to me, but I since Puppet comes packaged with Ruby there might be implications I haven’t thought of.

@chelnak
Copy link
Contributor

chelnak commented Sep 26, 2022

Yeah agree.

I just had a quick chat with @david22swan about this. It looks like 2.5 is the current minimum version so it would be nice to align here.

I can test this out shortly.

@chelnak chelnak self-assigned this Sep 26, 2022
@chelnak
Copy link
Contributor

chelnak commented Sep 26, 2022

Tested with ruby 2.5.7p206 (2019-10-01 revision 67816) [x86_64-darwin20] and Bundler version 2.3.6.

This appears to work so think this might be a nice compromise given that it brings it inline with the rest of the ecosystem.

@danielparks
Copy link
Contributor Author

Does that mean that the minimum Puppet version should be bumped to 7?

danielparks added a commit to danielparks/puppet-strings that referenced this issue Sep 26, 2022
Previously, the minimum Ruby version was 2.3.0, but it was dificult to
get it working and some of the code had been updated to use features as
new as 2.4.6.

This clears out code that checked for old Ruby versions, and removes
some version constraints in Gemfile that were needed to work with Ruby
2.3.0.
@danielparks
Copy link
Contributor Author

PR #313. Hopefully we weren’t both working on this; feel free to delete, etc.

@chelnak
Copy link
Contributor

chelnak commented Sep 26, 2022

It does slightly overlap. I am currently battling with some rubocop/spec issues that have occurred.

I will merge your changes and integrate in to my branch. Thanks!

With regards to the puppet version. I think it's OK to leave at 6 for now.

chelnak added a commit that referenced this issue Sep 26, 2022
(#301) Update minimum Ruby version to 2.5.0
@chelnak
Copy link
Contributor

chelnak commented Sep 26, 2022

Your changes are now in my branch

@danielparks
Copy link
Contributor Author

Hurrah!

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

No branches or pull requests

2 participants