Skip to content

feat: Support Ruby 4.0#238

Open
sue445 wants to merge 3 commits into
GoogleCloudPlatform:mainfrom
sue445:ruby_4.0
Open

feat: Support Ruby 4.0#238
sue445 wants to merge 3 commits into
GoogleCloudPlatform:mainfrom
sue445:ruby_4.0

Conversation

@sue445

@sue445 sue445 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Currently, the latest version of Ruby is the 4.0 series.

Running the code on Ruby 4.0.x results in the following error:

$ toys ci
/Users/sue445/workspace/github.com/GoogleCloudPlatform/functions-framework-ruby/lib/functions_framework.rb:15: warning: logger used to be loaded from the st
You can add logger to your Gemfile or gemspec to fix this error.
/Users/sue445/.rbenv/versions/4.0.2/lib/ruby/4.0.0/bundled_gems.rb:60:in 'Kernel.require': cannot load such file -- logger (LoadError)
$ toys ci
test/test_function.rb:16: warning: ostruct used to be loaded from the standard library, but is not part of the default gems since Ruby 4.0.0.
You can add ostruct to your Gemfile or gemspec to fix this error.
/Users/sue445/.rbenv/versions/4.0.2/lib/ruby/4.0.0/bundled_gems.rb:60:in 'Kernel.require': cannot load such file -- ostruct (LoadError)

This is caused by logger and ostruct being promoted from default gems to bundled gems in Ruby 4.0.0.

https://www.ruby-lang.org/en/news/2025/12/25/ruby-4-0-0-released/#stdlib-updates

Therefore, I have added these gems as runtime dependencies.

@sue445 sue445 changed the title Support Ruby 4.0 feat: Support Ruby 4.0 Jun 10, 2026
sue445 added 3 commits July 7, 2026 21:42
… Ruby 4.0

```
$ toys ci
/Users/sue445/workspace/github.com/GoogleCloudPlatform/functions-framework-ruby/lib/functions_framework.rb:15: warning: logger used to be loaded from the standard library, but is not part of the default gems since Ruby 4.0.0.
You can add logger to your Gemfile or gemspec to fix this error.
/Users/sue445/.rbenv/versions/4.0.2/lib/ruby/4.0.0/bundled_gems.rb:60:in 'Kernel.require': cannot load such file -- logger (LoadError)
	from /Users/sue445/.rbenv/versions/4.0.2/lib/ruby/4.0.0/bundled_gems.rb:60:in 'block (2 levels) in Kernel#replace_require'
	from /Users/sue445/workspace/github.com/GoogleCloudPlatform/functions-framework-ruby/lib/functions_framework.rb:15:in '<top (required)>'
	from /Users/sue445/.rbenv/versions/4.0.2/lib/ruby/4.0.0/bundled_gems.rb:60:in 'Kernel.require'
	from /Users/sue445/.rbenv/versions/4.0.2/lib/ruby/4.0.0/bundled_gems.rb:60:in 'block (2 levels) in Kernel#replace_require'
	from /Users/sue445/workspace/github.com/GoogleCloudPlatform/functions-framework-ruby/test/helper.rb:19:in '<top (required)>'
	from /Users/sue445/.rbenv/versions/4.0.2/lib/ruby/4.0.0/bundled_gems.rb:60:in 'Kernel.require'
	from /Users/sue445/.rbenv/versions/4.0.2/lib/ruby/4.0.0/bundled_gems.rb:60:in 'block (2 levels) in Kernel#replace_require'
```
…n Ruby 4.0

```
$ toys ci
test/test_function.rb:16: warning: ostruct used to be loaded from the standard library, but is not part of the default gems since Ruby 4.0.0.
You can add ostruct to your Gemfile or gemspec to fix this error.
/Users/sue445/.rbenv/versions/4.0.2/lib/ruby/4.0.0/bundled_gems.rb:60:in 'Kernel.require': cannot load such file -- ostruct (LoadError)
Did you mean?  tsort
	from /Users/sue445/.rbenv/versions/4.0.2/lib/ruby/4.0.0/bundled_gems.rb:60:in 'block (2 levels) in Kernel#replace_require'
	from test/test_function.rb:16:in '<top (required)>'
	from /var/folders/kh/pcns6sf91tnfk6k6b4vqtz8r0000gn/T/toys-minitest-script-20260611-15935-rmwq9y.rb:7:in 'Kernel#load'
	from /var/folders/kh/pcns6sf91tnfk6k6b4vqtz8r0000gn/T/toys-minitest-script-20260611-15935-rmwq9y.rb:7:in '<main>'
```
@sue445

sue445 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

I encountered a conflict with the main branch, so I have rebased and force-pushed the changes.
However, the following error is occurring in my repository's CI:

Run ruby/setup-ruby@472790540115ce5bd69d399a020189a8c87d641f
Error: Error: Unknown version 4.0 for ruby on ubuntu-24.04
        Available versions for ruby on ubuntu-24.04: 1.9.3-p551, 2.0.0-p648, 2.1.9, 2.2.10, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5, 2.3.6, 2.3.7, 2.3.8, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.9, 2.4.10, 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.5.6, 2.5.7, 2.5.8, 2.5.9, 2.6.0, 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.6.5, 2.6.6, 2.6.7, 2.6.8, 2.6.9, 2.6.10, 2.7.0, 2.7.1, 2.7.2, 2.7.3, 2.7.4, 2.7.5, 2.7.6, 2.7.7, 2.7.8, 3.0.0-preview1, 3.0.0-preview2, 3.0.0-rc1, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.1.0-preview1, 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.2.0-preview1, 3.2.0-preview2, 3.2.0-preview3, 3.2.0-rc1, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.2.7, 3.2.8, 3.3.0-preview1, 3.3.0-preview2, 3.3.0-preview3, 3.3.0-rc1, 3.3.0, 3.3.1, 3.3.2, 3.3.3, 3.3.4, 3.3.5, 3.3.6, 3.3.7, 3.3.8, 3.4.0-preview1, 3.4.0-preview2, 3.4.0-rc1, 3.4.0, 3.4.1, 3.4.2, 3.4.3, 3.4.4, 3.4.5, 3.5.0-preview1, head, debug, asan, 3.4-asan
        Make sure you use the latest version of the action with - uses: ruby/setup-ruby@v1

It seems that we may need to update ruby/setup-ruby to the latest version first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant