From 7b5b23d0c87a56947f6a4143982601eca102d860 Mon Sep 17 00:00:00 2001 From: rootkiller6788 Date: Thu, 20 Aug 2026 23:45:37 +0800 Subject: [PATCH] Fix NameError in custom_attrs sample hook The custom_attrs sample hook references Tmpfile, which is not a Ruby constant. The Ruby stdlib tempfile class is Tempfile, so calling Tmpfile.new in pre_start raises a NameError whenever --custom-attr is passed. Fix the typo and add the missing require 'tempfile'. Signed-off-by: rootkiller6788 --- chefctl/sample_hooks/custom_attrs.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chefctl/sample_hooks/custom_attrs.rb b/chefctl/sample_hooks/custom_attrs.rb index 7d5abe8..b65c66a 100644 --- a/chefctl/sample_hooks/custom_attrs.rb +++ b/chefctl/sample_hooks/custom_attrs.rb @@ -23,6 +23,7 @@ # documentation for descriptions of each method. require 'json' +require 'tempfile' module CustomAttributes def initialize @@ -41,7 +42,7 @@ def cli_options(parser) def pre_start if @custom_attr - @tmp_file = Tmpfile.new('attributes') + @tmp_file = Tempfile.new('attributes') attrs = { 'custom_attributes' => @custom_attr } @tmp_file.write(JSON.generate(attrs)) @tmp_file.close