Skip to content

Comments

gem: add ostruct gem as dependency for Ruby 4.0#461

Merged
kenhys merged 1 commit intofluent:masterfrom
Watson1978:gem
Feb 19, 2026
Merged

gem: add ostruct gem as dependency for Ruby 4.0#461
kenhys merged 1 commit intofluent:masterfrom
Watson1978:gem

Conversation

@Watson1978
Copy link
Contributor

@Watson1978 Watson1978 commented Feb 19, 2026

This patch will fix following error:

$ bundle exec rake test
/home/watson/.rbenv/versions/4.0.1/bin/ruby -w -I"lib:lib:test" /home/watson/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/rake-13.3.1/lib/rake/rake_test_loader.rb "test/test_in_s3.rb" "test/test_out_s3.rb"
/home/watson/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/fluentd-1.18.0/lib/fluent/plugin_helper.rb:46: warning: method redefined; discarding old inherited
/home/watson/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/fluentd-1.18.0/lib/fluent/plugin_helper.rb:46: warning: previous definition of inherited was here
/home/watson/src/fluent-plugin-s3/lib/fluent/plugin/in_s3.rb:7: warning: CGI::Util is removed from Ruby 4.0. Please use cgi/escape instead for CGI.escape and CGI.unescape features.
If you are using CGI.parse, please install and use the cgi gem instead.
/home/watson/src/fluent-plugin-s3/test/test_in_s3.rb:14: 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.
/home/watson/.rbenv/versions/4.0.1/lib/ruby/4.0.0/bundled_gems.rb:60:in 'Kernel.require': cannot load such file -- ostruct (LoadError)
Did you mean?  tsort
        from /home/watson/.rbenv/versions/4.0.1/lib/ruby/4.0.0/bundled_gems.rb:60:in 'block (2 levels) in Kernel#replace_require'
        from /home/watson/src/fluent-plugin-s3/test/test_in_s3.rb:14:in '<top (required)>'
        from /home/watson/.rbenv/versions/4.0.1/lib/ruby/4.0.0/bundled_gems.rb:60:in 'Kernel.require'
        from /home/watson/.rbenv/versions/4.0.1/lib/ruby/4.0.0/bundled_gems.rb:60:in 'block (2 levels) in Kernel#replace_require'
        from /home/watson/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/rake-13.3.1/lib/rake/rake_test_loader.rb:21:in 'block in <main>'
        from /home/watson/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/rake-13.3.1/lib/rake/rake_test_loader.rb:6:in 'Array#select'
        from /home/watson/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/rake-13.3.1/lib/rake/rake_test_loader.rb:6:in '<main>'
rake aborted!
Command failed with status (1): [ruby -w -I"lib:lib:test" /home/watson/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/rake-13.3.1/lib/rake/rake_test_loader.rb "test/test_in_s3.rb" "test/test_out_s3.rb" ]
/home/watson/.rbenv/versions/4.0.1/bin/bundle:25:in '<main>'
Tasks: TOP => test
(See full trace by running task with --trace)

We need to specify the ostruct gem as dependency because it is a bundled gem from Ruby 4.0.
Same reason with fluent/fluentd#5249

Ref:

require 'ostruct'
require 'ostruct'

This patch will fix following error:
```
$ bundle exec rake test
/home/watson/.rbenv/versions/4.0.1/bin/ruby -w -I"lib:lib:test" /home/watson/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/rake-13.3.1/lib/rake/rake_test_loader.rb "test/test_in_s3.rb" "test/test_out_s3.rb"
/home/watson/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/fluentd-1.18.0/lib/fluent/plugin_helper.rb:46: warning: method redefined; discarding old inherited
/home/watson/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/fluentd-1.18.0/lib/fluent/plugin_helper.rb:46: warning: previous definition of inherited was here
/home/watson/src/fluent-plugin-s3/lib/fluent/plugin/in_s3.rb:7: warning: CGI::Util is removed from Ruby 4.0. Please use cgi/escape instead for CGI.escape and CGI.unescape features.
If you are using CGI.parse, please install and use the cgi gem instead.
/home/watson/src/fluent-plugin-s3/test/test_in_s3.rb:14: 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.
/home/watson/.rbenv/versions/4.0.1/lib/ruby/4.0.0/bundled_gems.rb:60:in 'Kernel.require': cannot load such file -- ostruct (LoadError)
Did you mean?  tsort
        from /home/watson/.rbenv/versions/4.0.1/lib/ruby/4.0.0/bundled_gems.rb:60:in 'block (2 levels) in Kernel#replace_require'
        from /home/watson/src/fluent-plugin-s3/test/test_in_s3.rb:14:in '<top (required)>'
        from /home/watson/.rbenv/versions/4.0.1/lib/ruby/4.0.0/bundled_gems.rb:60:in 'Kernel.require'
        from /home/watson/.rbenv/versions/4.0.1/lib/ruby/4.0.0/bundled_gems.rb:60:in 'block (2 levels) in Kernel#replace_require'
        from /home/watson/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/rake-13.3.1/lib/rake/rake_test_loader.rb:21:in 'block in <main>'
        from /home/watson/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/rake-13.3.1/lib/rake/rake_test_loader.rb:6:in 'Array#select'
        from /home/watson/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/rake-13.3.1/lib/rake/rake_test_loader.rb:6:in '<main>'
rake aborted!
Command failed with status (1): [ruby -w -I"lib:lib:test" /home/watson/.rbenv/versions/4.0.1/lib/ruby/gems/4.0.0/gems/rake-13.3.1/lib/rake/rake_test_loader.rb "test/test_in_s3.rb" "test/test_out_s3.rb" ]
/home/watson/.rbenv/versions/4.0.1/bin/bundle:25:in '<main>'
Tasks: TOP => test
(See full trace by running task with --trace)
```

We need to specify the ostruct gem as dependency because it is a bundled gem from Ruby 4.0.
Same reason with fluent/fluentd#5249

Ref:
https://github.com/fluent/fluent-plugin-s3/blob/9e5e9e81f9449af466330a298ada50eadc631312/test/test_in_s3.rb#L14
https://github.com/fluent/fluent-plugin-s3/blob/9e5e9e81f9449af466330a298ada50eadc631312/test/test_out_s3.rb#L12

Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
@Watson1978 Watson1978 requested a review from kenhys February 19, 2026 01:48
Copy link
Contributor

@kenhys kenhys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@kenhys kenhys merged commit 2278860 into fluent:master Feb 19, 2026
7 checks passed
@Watson1978
Copy link
Contributor Author

Thanks.

@Watson1978 Watson1978 deleted the gem branch February 19, 2026 02:12
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.

2 participants