summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorsnehaldwivedi <sdwivedi@msystechnologies.com>2021-06-09 05:52:18 -0700
committerMarc A. Paradise <marc.paradise@gmail.com>2022-05-24 15:25:14 -0400
commitf859ba08cc51f79d34928316d50df8a9b8f7af1f (patch)
tree64c1ed6917bde550b124e9456c03cafb23bcf73a /lib/chef
parenta5e6b4e47c82fc9e741192006b98d0dec237c1fe (diff)
downloadchef-f859ba08cc51f79d34928316d50df8a9b8f7af1f.tar.gz
Knife upload: bad error message when a recipe has a syntax error
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/cookbook/syntax_check.rb4
1 files changed, 2 insertions, 2 deletions
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