diff --git a/Library/Homebrew/extend/os/linux/parser.rb b/Library/Homebrew/extend/os/linux/parser.rb index 0195c1f67b..fcbeb67f0b 100644 --- a/Library/Homebrew/extend/os/linux/parser.rb +++ b/Library/Homebrew/extend/os/linux/parser.rb @@ -15,9 +15,9 @@ module Homebrew return unless @args.respond_to?(:cask?) return unless @args.cask? - # NOTE: We don't raise a UsageError here because - # we don't want to print the help page. - raise "Invalid usage: Casks are not supported on Linux" + # NOTE: We don't raise an error here because we don't want + # to print the help page or a stack trace. + odie "Invalid `--cask` usage: Casks do not work on Linux" end end end diff --git a/Library/Homebrew/test/cli/parser_spec.rb b/Library/Homebrew/test/cli/parser_spec.rb index 51ab257815..8711931858 100644 --- a/Library/Homebrew/test/cli/parser_spec.rb +++ b/Library/Homebrew/test/cli/parser_spec.rb @@ -573,7 +573,9 @@ describe Homebrew::CLI::Parser do it "throws an error when defined" do expect { parser.parse(["--cask"]) } - .to raise_error RuntimeError, "Invalid usage: Casks are not supported on Linux" + .to output("Error: Invalid `--cask` usage: Casks do not work on Linux\n").to_stderr + .and not_to_output.to_stdout + .and raise_exception SystemExit end end @@ -588,12 +590,16 @@ describe Homebrew::CLI::Parser do it "throws an error when --cask defined" do expect { parser.parse(["--cask"]) } - .to raise_error RuntimeError, "Invalid usage: Casks are not supported on Linux" + .to output("Error: Invalid `--cask` usage: Casks do not work on Linux\n").to_stderr + .and not_to_output.to_stdout + .and raise_exception SystemExit end it "throws an error when both defined" do expect { parser.parse(["--cask", "--formula"]) } - .to raise_error RuntimeError, "Invalid usage: Casks are not supported on Linux" + .to output("Error: Invalid `--cask` usage: Casks do not work on Linux\n").to_stderr + .and not_to_output.to_stdout + .and raise_exception SystemExit end end end