Skip to content
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

Add required_ruby_version to gemspec to require Ruby 3.1.0 or greater #317

Closed
synthead opened this issue Aug 2, 2023 · 0 comments · Fixed by #318
Closed

Add required_ruby_version to gemspec to require Ruby 3.1.0 or greater #317

synthead opened this issue Aug 2, 2023 · 0 comments · Fixed by #318
Assignees
Labels
bug Something isn't working

Comments

@synthead
Copy link
Owner

synthead commented Aug 2, 2023

Related to #316.

The gemspec doesn't specify a minimum Ruby version, and this lib uses omitted keyword arguments, which is a feature introduced in Ruby 3.1.0:

  • Values in Hash literals and keyword arguments can be omitted. [Feature #14579]

    • {x:, y:} is syntax sugar for {x: x, y: y}.
    • foo(x:, y:) is syntax sugar for foo(x: x, y: y).

This means that it's possible to install the timex_datalink_client gem on a version of Ruby that is too old, i.e. 3.0.6. When attempting to use the gem on 3.0.6, this exception is raised:

<internal:/home/elaine/.rbenv/versions/3.0.6/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': /home/elaine/repos/timex_datalink_client/lib/timex_datalink_client.rb:127: syntax error, unexpected ',' (SyntaxError)
      serial_device:,
                    ^
	from <internal:/home/elaine/.rbenv/versions/3.0.6/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from examples/protocol_7/clear-data:10:in `<main>'

A minimum version of 3.1.0 should be set by adding this to the gemspec:

s.required_ruby_version = ">= 3.1.0"

This will present a definitive error to the user if they attempt to install this gem on an older version:

timex_datalink_client-0.12.3 requires ruby version >= 3.1.0, which is incompatible with the current version, ruby 3.0.6p216
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant