brew
                                
                                 brew copied to clipboard
                                
                                    brew copied to clipboard
                            
                            
                            
                        After a fresh install, `brew list` shows an empty output if only cask(s) had been installed
brew config output
HOMEBREW_VERSION: 3.5.6
ORIGIN: https://github.com/Homebrew/brew
HEAD: 0b030b74e2ac518bd0bc4158f96c449198f9957f
Last commit: 7 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 48f398548302e5aef01a1202465c2831873df41d
Core tap last commit: 12 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 2.6.8 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: 10-core 64-bit arm_firestorm_icestorm
Clang: 13.1.6 build 1316
Git: 2.32.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.79.1 => /usr/bin/curl
macOS: 12.5-arm64
CLT: N/A
Xcode: 13.4.1
Rosetta 2: false
brew doctor output
Your system is ready to brew.
Verification
- [X] I ran brew updateand am still able to reproduce my issue.
- [X] I have resolved all warnings from brew doctorand that did not fix my problem.
What were you trying to do (and why)?
I installed brew following the instructions in https://docs.brew.sh/Installation#untar-anywhere.
Then, without installing any formula, I installed a cask. Example: brew install --cask ghidra.
Then, I ran brew list to see what I have installed.
What happened (include all command output)?
$ brew list
$
(The output is empty.)
I have also checked that the return code in $? is 0.
What did you expect to happen?
I expect brew list to show me a casks list (in my example, it would contain ghidra).
Note that once I install the first formula, then the output of brew list will become correct and show both the formula and the cask. And even if I uninstall that formula immediately, the output of brew list will remain correct and contain an empty formulae list and a casks list of one item.
Step-by-step reproduction instructions (by running brew commands)
In a fresh brew installation:
brew install --cask ghidra
brew list
Does this work?
# In a fresh brew installation:
brew install --cask ghidra
brew list --cask
@carlocab To answer your question, that would still yield an empty output.
I did some more testing this morning and I think the following may be useful. The initial setup is:
----starting from a fresh installation----
$ brew install --cask ghidra
$ brew list
$ brew list --cask
The cask installation step above created a subdirectory Caskroom inside the brew prefix (but note the absence of the Cellar subdirectory at this point). Despite the cask installation was successful, the output of both brew list and brew list --cask were empty.
But if we manually create a subdirectory called Cellar inside the brew prefix, then brew list will show a list of casks:
$ mkdir `brew --prefix`/Cellar
$ brew list
==> Casks
ghidra
And if we then further create a file inside Cellar, then brew list will show a list of formulae also:
$ touch `brew --prefix`/Cellar/.keepme
$ brew list
==> Formulae
==> Casks
ghidra
So I think the problem I was running into is: the installation method in https://docs.brew.sh/Installation#untar-anywhere does not create the Cellar subdirectory inside the brew prefix, and yet the absence of this subdirectory caused a bug in brew list (and brew list --cask) to not list any casks even when there are installed casks.
This is really just a bug in brew list. We currently return early if HOMEBREW_CELLAR doesn't exist, but this ignores the case where there are casks installed and not formulae. Instead of returning, we should continue execution and skip formula-specific things.
It looks like there's only one direct call to HOMEBREW_CELLAR later on in the file, and it already has an existence check, so I bet removing the early return would be pretty simple.
Anyone should feel free to take a stab at this, so marking as help wanted