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

warning: literal string will be frozen in the future since Ruby 3.4.0 #4585

Open
Watson1978 opened this issue Aug 9, 2024 · 0 comments
Open
Labels
pending To be done in the future

Comments

@Watson1978
Copy link
Contributor

Watson1978 commented Aug 9, 2024

Describe the bug

warning: literal string will be frozen in the future since Ruby 3.4.0

According to https://bugs.ruby-lang.org/issues/20205,
String literals may be frozen by default in the future (maybe Ruby 4.0+).

A transition period will be provided for this change,
the warning is only displayed when Ruby is started with the -w option enabled at present.

In fact, if we run the test in Ruby HEAD, we will encounter many warnings.
https://github.com/fluent/fluentd/actions/runs/10277576606

While the performance gains are attractive,
it will affect all Ruby code used by fluentd if string literals were frozen by default:

  • Fluentd
  • Dependent gem libraries
  • Fluentd plugins

Then, I investigate logs in https://github.com/fluent/fluentd/actions/runs/10277576606,
seems that the msgpack, rr gems and Fluentd main codes encounter the warnings when running tests at present.

/home/runner/.rubies/ruby-head/lib/ruby/gems/3.4.0+0/gems/msgpack-1.7.2/lib/msgpack.rb
/home/runner/.rubies/ruby-head/lib/ruby/gems/3.4.0+0/gems/rr-3.1.0/lib/rr/double_definitions/strategies/double_injection/instance.rb
/home/runner/work/fluentd/fluentd/lib/fluent/command/ctl.rb
/home/runner/work/fluentd/fluentd/lib/fluent/command/plugin_config_formatter.rb
/home/runner/work/fluentd/fluentd/lib/fluent/compat/record_filter_mixin.rb
/home/runner/work/fluentd/fluentd/lib/fluent/config/element.rb
/home/runner/work/fluentd/fluentd/lib/fluent/config/literal_parser.rb
/home/runner/work/fluentd/fluentd/lib/fluent/config/types.rb
/home/runner/work/fluentd/fluentd/lib/fluent/log.rb
/home/runner/work/fluentd/fluentd/lib/fluent/match.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin/buffer/file_chunk.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin/buffer/memory_chunk.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin/compressable.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin/formatter_csv.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin/formatter_ltsv.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin/formatter_out_file.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin/in_http.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin/in_monitor_agent.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin/in_syslog.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin/in_tail.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin/in_tcp.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin/out_forward/handshake_protocol.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin/parser_csv.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin_helper/http_server/server.rb
/home/runner/work/fluentd/fluentd/lib/fluent/plugin_helper/server.rb
/home/runner/work/fluentd/fluentd/lib/fluent/test/output_test.rb
/home/runner/work/fluentd/fluentd/test/command/test_fluentd.rb
/home/runner/work/fluentd/fluentd/test/plugin/in_tail/test_fifo.rb
/home/runner/work/fluentd/fluentd/test/plugin/in_tail/test_io_handler.rb
/home/runner/work/fluentd/fluentd/test/plugin/test_buffer_chunk.rb
/home/runner/work/fluentd/fluentd/test/plugin/test_buffer_file_chunk.rb
/home/runner/work/fluentd/fluentd/test/plugin/test_buffer_file_single_chunk.rb
/home/runner/work/fluentd/fluentd/test/plugin/test_buffer_memory_chunk.rb
/home/runner/work/fluentd/fluentd/test/plugin/test_filter_grep.rb
/home/runner/work/fluentd/fluentd/test/plugin/test_filter_parser.rb
/home/runner/work/fluentd/fluentd/test/plugin/test_in_forward.rb
/home/runner/work/fluentd/fluentd/test/plugin/test_in_tail.rb
/home/runner/work/fluentd/fluentd/test/plugin/test_in_unix.rb
/home/runner/work/fluentd/fluentd/test/plugin/test_out_file.rb
/home/runner/work/fluentd/fluentd/test/plugin/test_out_secondary_file.rb
/home/runner/work/fluentd/fluentd/test/plugin_helper/test_retry_state.rb
/home/runner/work/fluentd/fluentd/test/plugin_helper/test_server.rb

However, the Fluentd plugins are not included.
We may need to set RUBYOPT="-disable=frozen_string_literal" to run Fluentd safely.

To Reproduce

Run test on Ruby HEAD

Expected behavior

Works well

Your Environment

- Fluentd version:
- Package version:
- Operating system:
- Kernel version:

Your Configuration

none

Your Error Log

https://github.com/fluent/fluentd/actions/runs/10277576606

Additional context

No response

Watson1978 added a commit to Watson1978/fluentd that referenced this issue Aug 9, 2024
According to https://bugs.ruby-lang.org/issues/20205,
it will enable `# frozen_string_literal: true` by default in the future Ruby.

This changing will affect many Fluentd plugins, and they will require to be deal with it properly.
But I think it is too tough.

So, this patch will set `--disable=frozen_string_literal` as launch option to disable default behavior for `# frozen_string_literal: true` in future Ruby.

GitHub: fluentGH-4585
Signed-off-by: Watson <[email protected]>
@Watson1978 Watson1978 added pending To be done in the future and removed work-in-progress labels Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending To be done in the future
Projects
None yet
Development

No branches or pull requests

2 participants