From 4dccc2ef7f48e25a90a64701531bc88f2ffa31ef Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Mon, 22 Mar 2021 17:15:56 +0000 Subject: [PATCH] cmd/list: list formulae only if one is installed We need the `HOMEBREW_CELLAR.exist?` check to avoid errors in new installations, which may not have a `Cellar` directory. --- Library/Homebrew/cmd/list.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index 52f853ea66..6d05addb80 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -116,8 +116,10 @@ module Homebrew ls_args << "-r" if args.r? ls_args << "-t" if args.t? - ohai "Formulae" if $stdout.tty? && !args.formula? - safe_system "ls", *ls_args, HOMEBREW_CELLAR + if HOMEBREW_CELLAR.exist? && HOMEBREW_CELLAR.children.any? + ohai "Formulae" if $stdout.tty? && !args.formula? + safe_system "ls", *ls_args, HOMEBREW_CELLAR + end if !args.formula? && Cask::Caskroom.casks.any? if $stdout.tty?