Description
When using ruby 3.1 or 3.2 and running chef-run, if an error occurs, the following internal error is outputted: (see "client output").
I don't know if chef-apply is supposed to be used with ruby 3.x and that this issue should be reported. Ruby 3.1 introduced several breaking changes with YAML module, including change to YAML.load arguments. After the following change issue no longer remains and the error message is outputted correctly:
diff --git a/lib/chef_apply/text.rb b/lib/chef_apply/text.rb
index 850eb2d..7c4ccdc 100644
--- a/lib/chef_apply/text.rb
+++ b/lib/chef_apply/text.rb
@@ -28,7 +28,7 @@ module ChefApply
# error metadata.
path = File.join(_translation_path, "errors", "en.yml")
raw_yaml = File.read(path)
- @error_table ||= YAML.load(raw_yaml, _translation_path, symbolize_names: true)[:errors]
+ @error_table ||= YAML.load(raw_yaml, filename: _translation_path, symbolize_names: true)[:errors]
end
def self._translation_path
Chef Apply Version
0.9.4
Platform Version
Mac OS 10.13.6 x86_64
Replication Case
# use ruby 3.1 or 3.2
cd /tmp
chef generate cookbook test_cookbook
cd test_cookbook
echo 'remote_file "example" { }' > recipes/default.rb
chef-run somehost .
Client Output
[✔] Packaging cookbook... done!
[\] Generating local policyfile.../Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/ffi-yajl-2.4.0/lib/ffi_yajl/encoder.rb:42: warning: undefining the allocator of T_DATA class FFI_Yajl::Ext::Encoder::YajlGen
[✔] Generating local policyfile... exporting... done!
[✖] Applying … from … to target.
└── [✖] […] Failed to converge ….
INTERNAL ERROR
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Message:
wrong number of arguments (given 2, expected 1)
Backtrace:
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/3.2.0/psych.rb:368:in `load'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/lib/chef_apply/text.rb:31:in `_error_table'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/lib/chef_apply/text/error_translation.rb:27:in `initialize'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/lib/chef_apply/ui/error_printer.rb:103:in `new'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/lib/chef_apply/ui/error_printer.rb:103:in `initialize'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/lib/chef_apply/ui/error_printer.rb:71:in `new'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/lib/chef_apply/ui/error_printer.rb:71:in `write_backtrace'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/lib/chef_apply/cli.rb:328:in `capture_exception_backtrace'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/lib/chef_apply/cli.rb:293:in `handle_perform_error'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/lib/chef_apply/cli.rb:123:in `rescue in perform_run'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/lib/chef_apply/cli.rb:116:in `perform_run'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/lib/chef_apply/cli.rb:73:in `block in run'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-telemetry-1.1.1/lib/chef/telemeter.rb:75:in `block in timed_capture'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/3.2.0/benchmark.rb:296:in `measure'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-telemetry-1.1.1/lib/chef/telemeter.rb:75:in `timed_capture'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-telemetry-1.1.1/lib/chef/telemeter.rb:71:in `timed_run_capture'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/3.2.0/forwardable.rb:240:in `timed_run_capture'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/lib/chef_apply/cli.rb:71:in `run'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/lib/chef_apply/startup.rb:199:in `start_chef_apply'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/lib/chef_apply/startup.rb:65:in `run'
/Users/kolen/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/chef-apply-0.9.4/bin/chef-run:23:in `<top (required)>'
/Users/kolen/.rbenv/versions/3.2.0/bin/chef-run:25:in `load'
/Users/kolen/.rbenv/versions/3.2.0/bin/chef-run:25:in `<main>'
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Stacktrace
See above
Description
When using ruby 3.1 or 3.2 and running
chef-run, if an error occurs, the following internal error is outputted: (see "client output").I don't know if chef-apply is supposed to be used with ruby 3.x and that this issue should be reported. Ruby 3.1 introduced several breaking changes with YAML module, including change to
YAML.loadarguments. After the following change issue no longer remains and the error message is outputted correctly:Chef Apply Version
0.9.4
Platform Version
Mac OS 10.13.6 x86_64
Replication Case
Client Output
Stacktrace
See above