From f859ba08cc51f79d34928316d50df8a9b8f7af1f Mon Sep 17 00:00:00 2001 From: snehaldwivedi Date: Wed, 9 Jun 2021 05:52:18 -0700 Subject: Knife upload: bad error message when a recipe has a syntax error Signed-off-by: snehaldwivedi --- lib/chef/cookbook/syntax_check.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/chef') diff --git a/lib/chef/cookbook/syntax_check.rb b/lib/chef/cookbook/syntax_check.rb index 555d2f6715..d94b7ed074 100644 --- a/lib/chef/cookbook/syntax_check.rb +++ b/lib/chef/cookbook/syntax_check.rb @@ -248,8 +248,8 @@ class Chef # Debugs ruby syntax errors by printing the path to the file and any # diagnostic info given in +error_message+ def invalid_ruby_file(ruby_file, error_message) - file_relative_path = ruby_file[/^#{Regexp.escape(cookbook_path + File::Separator)}(.*)/, 1] - Chef::Log.fatal("Cookbook file #{file_relative_path} has a ruby syntax error:") + file_relative_path = File.basename(ruby_file) + Chef::Log.fatal("Cookbook file #{file_relative_path} has a ruby syntax error.") error_message.each_line { |l| Chef::Log.fatal(l.chomp) } false end -- cgit v1.2.1