Skip to content

Fix required_ruby_version in gemspec to support Ruby 3.0+ #418

@nc163

Description

@nc163

Describe the bug
The spec.required_ruby_version is currently set to '>= 2.7.0', which allows installation on Ruby 2.7.x environments. However, the library fails to function correctly on any Ruby version below 3.0.

To Reproduce
Steps to reproduce the behavior:

  • Prepare an environment with Ruby 2.7.x.
  • Add the gem to the Gemfile or install it directly.
  • Require the library in a Ruby script (e.g., require 'mcp').
  • Observe the SyntaxError occurring during the load process, as the Ruby parser fails to interpret the argument forwarding syntax in server_context.rb.

Expected behavior
The gemspec should be updated to '>= 3.0.0' to ensure that the installation is restricted to compatible Ruby versions and fails early for unsupported environments.

Logs

SyntaxError:
       /usr/lib/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/mcp-0.18.0/lib/mcp/server_context.rb:133: syntax error, unexpected (...
       ...   def method_missing(name, ...)
       ...                            ^~~
       /usr/lib/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/mcp-0.18.0/lib/mcp/server_context.rb:135: syntax error, unexpected ')'
       ...@context.public_send(name, ...)
       ...                              ^
       /usr/lib/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/mcp-0.18.0/lib/mcp/server_context.rb:145: syntax error, unexpected `end', expecting end-of-input

Additional context
This library uses the argument forwarding syntax, which was introduced in Ruby 3.0.
Reference: https://www.ruby-lang.org/ja/news/2020/12/25/ruby-3-0-0-released/

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions