From 8b17017108d5b550562b556c5d407361cea27781 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 21 Dec 2020 15:45:18 +0100 Subject: [PATCH] Improve error message for missing PKG source. --- Library/Homebrew/cask/artifact/pkg.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/artifact/pkg.rb b/Library/Homebrew/cask/artifact/pkg.rb index ae717a3e7e..f6eef1e42c 100644 --- a/Library/Homebrew/cask/artifact/pkg.rb +++ b/Library/Homebrew/cask/artifact/pkg.rb @@ -42,7 +42,14 @@ module Cask ohai "Running installer for #{cask}; your password may be necessary." ohai "Package installers may write to any location; options such as --appdir are ignored." unless path.exist? - raise CaskError, "pkg source file not found: '#{path.relative_path_from(cask.staged_path)}'" + pkg = path.relative_path_from(cask.staged_path) + pkgs = Pathname.glob(cask.staged_path/"**"/"*.pkg").map { |path| path.relative_path_from(cask.staged_path) } + + message = "Could not find PKG source file '#{pkg}'" + message += ", found #{pkgs.map { |path| "'#{path}'" }.to_sentence} instead" if pkgs.any? + message += "." + + raise CaskError, message end args = [