Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
41.64k stars 9.79k forks source link

`brew leaves --installed-as-dependency` blows up with a stack trace #17199

Closed bootc closed 7 months ago

bootc commented 7 months ago

brew doctor output

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  container-diff

Warning: Putting non-prefixed coreutils in your path can cause GMP builds to fail.

Warning: Putting non-prefixed findutils in your path can cause python builds to fail.

Verification

brew config output

HOMEBREW_VERSION: 4.2.20-60-g542edec
ORIGIN: https://github.com/Homebrew/brew
HEAD: 542edec0ff9224abe84d7ab6943b230489eac411
Last commit: 13 minutes ago
Core tap JSON: 01 May 15:44 UTC
Core cask tap JSON: 01 May 15:44 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: vim
HOMEBREW_MAKE_JOBS: 10
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.1.4 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: 10-core 64-bit arm_firestorm_icestorm
Clang: 15.0.0 build 1500
Git: 2.45.0 => /opt/homebrew/bin/git
Curl: 8.6.0 => /usr/bin/curl
macOS: 14.5-arm64
CLT: 15.3.0.0.1.1708646388
Xcode: 15.3
Rosetta 2: false

What were you trying to do (and why)?

I was trying to run brew leaves --installed-as-dependency to list formulae that I may no longer need to have installed on my system.

What happened (include all command output)?

$ brew leaves --installed-as-dependency
Error: undefined method `installed_as_dependency' for #<Keg:/opt/homebrew/Cellar/mosh/1.4.0_14>
Warning: Removed Sorbet lines from backtrace!
Rerun with `--verbose` to see the original backtrace
/opt/homebrew/Library/Homebrew/cmd/leaves.rb:47:in `installed_as_dependency?'
/opt/homebrew/Library/Homebrew/cmd/leaves.rb:33:in `block in run'
/opt/homebrew/Library/Homebrew/cmd/leaves.rb:33:in `select!'
/opt/homebrew/Library/Homebrew/cmd/leaves.rb:33:in `run'
/opt/homebrew/Library/Homebrew/brew.rb:92:in `<main>'
Please report this issue:
  https://docs.brew.sh/Troubleshooting

What did you expect to happen?

A nice short list of a handful of packages I could look into removing. That's what usually happens.

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

1. `brew leaves --installed-as-dependency`
2. That's it.
bootc commented 7 months ago

I should add brew doctor does not say Your system is ready to brew.. I've never seen that before...

bootc commented 7 months ago

This started out as https://github.com/orgs/Homebrew/discussions/5331.

ZhongRuoyu commented 7 months ago

Thanks for the report; this should be fixed by the above PR. You can get the fix in the next release, or by running HOMEBREW_DEVELOPER=1 brew update.

bootc commented 7 months ago

Thanks, looks good today:

$ brew upgrade 
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Auto-updated Homebrew!
==> Updated Homebrew from 542edec0ff92 to b5b37d8c8054.
[...]
$ brew leaves --installed-as-dependency
[after all that, there were none!]