brew list does not output casks

Created on 9 Sep 2020  路  13Comments  路  Source: Homebrew/brew

Bug report

  • [x] ran brew update and can still reproduce the problem?
  • [x] ran brew doctor, fixed all issues and can still reproduce the problem?
  • [ ] ran brew config and brew doctor and included their output with your issue?

What you were trying to do (and why)

Understand what brew list does, now that brew cask list is deprecated.

What happened (include command output)

Running brew list only displays formulae, which duplicates --formulae flag.

What you expected to happen

Brew list should either return both casks and formulae, or the description of the command should be clarified to explain that it return formulae only by default (either in the description itself or in the description of the --formulae flag).

Related: does brew upgrade upgrade both casks and formulae by default?

Step-by-step reproduction instructions (by running brew commands)

brew list

Output of brew config and brew doctor commands - NA

help wanted

Most helpful comment

This will break backwards compatibility (which we don't want to do).

We could show both with brew list when on a TTY and print a warning when not on a TTY to switch to passing --formulae explicitly so we can eventually change the non-TTY behaviour to include both as well.

All 13 comments

Thanks for the issue - the behaviour does seem to be inconsistent with the description text!

Related: does brew upgrade upgrade both casks and formulae by default?

Yes, it does.

Looks like it's intentional for brew list to return brew list --formula, for backwards compatibility.

  1. Thoughts on updating the --formula flag description to end with This is the default action.? Should that part be in bold? Happy to open a PR.
  2. Another thing that could be made more clear is that brew list [cask] won't work, and that instead you should use brew list --cask [cask]. Thoughts on updating --cask flag description:
List only casks, or [cask] if provided.

(Text in brackets would be underlined).

Looks like it's intentional for brew list to return brew list --formula, for backwards compatibility.

  1. Thoughts on updating the --formula flag description to end with This is the default action.? Should that part be in bold? Happy to open a PR.

If its the default option, is there a reason for it to be listed at all? When would --formula ever be passed? I'd remove it if there are no use cases.

  1. Another thing that could be made more clear is that brew list [cask] won't work, and that instead you should use brew list --cask [cask]. Thoughts on updating --cask flag description:

Any reason why it shouldn't work by default?

In my mind, the way it should work is as follows:

  • brew list lists all formulae and casks that are installed
  • brew list --formulae (or brew list --only-formulae) lists only formulae that are installed
  • brew list --casks (or brew list --only-casks) lists only casks that are installed
  • brew list X will list the paths associated with both the formula X and the cask X
  • brew list --formula X will list the paths associated with only the formula X
  • brew list --cask X will list the paths associated with only the cask X

It's possible that there's a reason for this that I don't know about. If so, please share.

  • brew list lists all formulae and casks that are installed

This will break backwards compatibility (which we don't want to do).

When would --formula ever be passed?

To be explicit and allow for potential change in future. Also because other commands accept --formula.

Hey all - any interest in my suggestions? Or should I close this issue? Thanks!

@JBallin Sorry, yes, both of those sound good 馃憤馃徎

This will break backwards compatibility (which we don't want to do).

We could show both with brew list when on a TTY and print a warning when not on a TTY to switch to passing --formulae explicitly so we can eventually change the non-TTY behaviour to include both as well.

We could show both with brew list when on a TTY and print a warning when not on a TTY to switch to passing --formulae explicitly so we can eventually change the non-TTY behaviour to include both as well.

Yeh, this is a good idea.

I can try to take a stab at this feature when I have bandwidth - but I can't guarantee a quick turnaround. Open to others contributing the change.

At this line: https://github.com/Homebrew/brew/blob/5133b4cf89b0acc6d06d9eea1eaea2ceaed11441/Library/Homebrew/cmd/list.rb#L89
Should it be something like this?

        if !$stdout.tty? && !args.formula?
          puts "Explicitly passed --formula"
          safe_system "ls", *ls_args, HOMEBREW_CELLAR
        else
          safe_system "ls", *ls_args, HOMEBREW_CELLAR
          ls_args.delete "-1"
          if !args.formula? and ls_args.length == 0
            print list_casks(args: args)
          end
        end

@Akylzhan, something like that, yeah. Just push it to your PR, it's easier to review that way.

This was fixed.

Was this page helpful?
0 / 5 - 0 ratings