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

Require Ruby 3.1.0 or greater in gemspec #318

Merged
merged 1 commit into from
Aug 2, 2023

Conversation

synthead
Copy link
Owner

@synthead synthead commented Aug 2, 2023

Fixes #317!

Adds s.required_ruby_version = ">= 3.1.0" to require Ruby 3.1.0 or greater, which is the minimum-supported version of this gem.

From #317:

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

@synthead synthead added the bug Something isn't working label Aug 2, 2023
@synthead synthead self-assigned this Aug 2, 2023
@synthead synthead merged commit d3b1d88 into main Aug 2, 2023
@synthead synthead deleted the add-required_ruby_version-to-gemspec branch August 2, 2023 04:01
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 this pull request may close these issues.

Add required_ruby_version to gemspec to require Ruby 3.1.0 or greater
1 participant