Skip to content

Commit 63ee9eb

Browse files
authored
command/fluentd: load win32/registry when edit registry for Ruby 4.0 (#5213)
**Which issue(s) this PR fixes**: Fixes # **What this PR does / why we need it**: When edit Windows registry like `ruby bin/fluentd --reg-winsvc-fluentdopt "-c '$current_path/duplicated_id.conf' -o '$log_path'"`, Ruby 4.0 causes `uninitialized constant Win32::Registry (NameError)`. Ref. https://github.com/fluent/fluentd/actions/runs/20650937408/job/59296698869 Ruby 3.4 has bundled resolv v0.6.2, which loads `win32/registry`. https://github.com/ruby/resolv/blob/a28aaed4cb700303227f0e81178baf93d6221621/ext/win32/resolv/lib/resolv.rb#L46C15-L46C31 Therefore, we can use `Win32::Registry` implicitly after loading resolv. It has been removed in the latest version of resolv gem. **Docs Changes**: **Release Note**: Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
1 parent 088cb0c commit 63ee9eb

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/fluent/command/fluentd.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@
344344
end
345345

346346
if fluentdopt = opts[:fluentdopt]
347+
require "win32/registry"
347348
Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Services\\#{opts[:winsvc_name]}", Win32::Registry::KEY_ALL_ACCESS) do |reg|
348349
reg['fluentdopt', Win32::Registry::REG_SZ] = fluentdopt
349350
end

0 commit comments

Comments
 (0)