From 9f4c9dc31c49fae98171ffca9a9c7cddcb64f15a Mon Sep 17 00:00:00 2001 From: Watson Date: Fri, 9 Aug 2024 16:24:06 +0900 Subject: [PATCH] Disable default behavior of frozen_string_literal for Ruby 3.4+ 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: GH-4585 Signed-off-by: Watson --- Rakefile | 2 +- lib/fluent/supervisor.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index cf7ac11004..70339b0906 100755 --- a/Rakefile +++ b/Rakefile @@ -43,7 +43,7 @@ Rake::TestTask.new(:base_test) do |t| end t.verbose = true t.warning = true - t.ruby_opts = ["-Eascii-8bit:ascii-8bit"] + t.ruby_opts = ["-Eascii-8bit:ascii-8bit --disable=frozen_string_literal"] end task :parallel_test do diff --git a/lib/fluent/supervisor.rb b/lib/fluent/supervisor.rb index 5c1018c9c7..a4ae3ee868 100644 --- a/lib/fluent/supervisor.rb +++ b/lib/fluent/supervisor.rb @@ -1019,6 +1019,8 @@ def build_spawn_command fluentd_spawn_cmd = [ServerEngine.ruby_bin_path] end + fluentd_spawn_cmd << '--disable=frozen_string_literal' + rubyopt = ENV['RUBYOPT'] if rubyopt encodes, others = rubyopt.split(' ').partition { |e| e.match?(RUBY_ENCODING_OPTIONS_REGEX) }