Homebrew / brew

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

`brew desc --eval-all --search SEARCHTERM` fails with confusing message #16188

Closed jwodder closed 10 months ago

jwodder commented 10 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:
  hdf5@1.8
  openssl@1.1

Verification

brew config output

HOMEBREW_VERSION: 4.1.18
ORIGIN: https://github.com/Homebrew/brew
HEAD: bf8991f0d777fe8e33105f0cd7bf1e5993eed60a
Last commit: 8 days ago
Core tap JSON: 06 Nov 10:59 UTC
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_CLEANUP_MAX_AGE_DAYS: 1
HOMEBREW_EDITOR: /usr/local/bin/vim
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.10 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit icelake
Clang: 15.0.0 build 1500
Git: 2.42.1 => /usr/local/bin/git
Curl: 8.1.2 => /usr/bin/curl
macOS: 14.0-x86_64
CLT: 15.0.0.0.1.1694021235
Xcode: N/A

What were you trying to do (and why)?

I was trying to search through all available formulae using brew desc --search. The error message I got told me to use --eval-all, so I did, but I still got an error unless I instead set HOMEBREW_EVAL_ALL=1. Interestingly, --eval-all does work when not using the --search option

What happened (include all command output)?

$ brew desc -s unicode
Usage: brew desc [options] formula|cask|text|/regex/ [...]

Display formula's name and one-line description. The cache is created on the
first search, making that search slower than subsequent ones.

  -s, --search                     Search both names and descriptions for
                                   text. If text is flanked by slashes, it
                                   is interpreted as a regular expression.
  -n, --name                       Search just names for text. If text is
                                   flanked by slashes, it is interpreted as a
                                   regular expression.
  -d, --description                Search just descriptions for text. If
                                   text is flanked by slashes, it is
                                   interpreted as a regular expression.
      --eval-all                   Evaluate all available formulae and casks,
                                   whether installed or not, to search their
                                   descriptions. Implied if HOMEBREW_EVAL_ALL
                                   is set.
      --formula, --formulae        Treat all named arguments as formulae.
      --cask, --casks              Treat all named arguments as casks.
      --debug                      Display any debugging information.
  -q, --quiet                      Make some output more quiet.
  -v, --verbose                    Make some output more verbose.
  -h, --help                       Show this message.

Error: Invalid usage: `brew desc` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!
[1]
$ brew desc --eval-all -s unicode
==> Formulae
Error: Calling Formula#all without --eval-all or HOMEBREW_EVAL_ALL is disabled! There is no replacement.
[1]
$ brew --eval-all desc -s unicode
Error: Unknown command: --eval-all
[1]
$ brew desc -s unicode --eval-all
==> Formulae
Error: Calling Formula#all without --eval-all or HOMEBREW_EVAL_ALL is disabled! There is no replacement.
[1]
$ brew desc --search unicode --eval-all
==> Formulae
Error: Calling Formula#all without --eval-all or HOMEBREW_EVAL_ALL is disabled! There is no replacement.
[1]
$ brew desc --eval-all just
just: Handy way to save and run project-specific commands
$ HOMEBREW_EVAL_ALL=1 brew desc -s unicode
==> Formulae
ansiweather: Weather in your terminal, with ANSI colors and Unicode symbols
chafa: Versatile and fast Unicode/ASCII/ANSI graphics renderer
chars: Command-line tool to display information about unicode characters
fribidi: Implementation of the Unicode BiDi algorithm
glktermw: Terminal-window Glk library with Unicode support
gucharmap: GNOME Character Map, based on the Unicode Character Database
icu4c: C/C++ and Java libraries for Unicode and globalization
libgrapheme: Unicode string library
libunibreak: Implementation of the Unicode line- and word-breaking algorithms
libuninameslist: Library of Unicode names and annotation data
libunistring: C string library for manipulating Unicode strings
mp3unicode: Command-line utility to convert mp3 tags between different encodings
rxvt-unicode: Rxvt fork with Unicode support
simdutf: Unicode conversion routines, fast
uni: Unicode database query tool for the command-line
uniutils: Manipulate and analyze Unicode text
unum: Interconvert numbers, Unicode, and HTML/XHTML entities
utf8proc: Clean C library for processing UTF-8 Unicode data
wordgrinder: Unicode-aware word processor that runs in a terminal

==> Casks

What did you expect to happen?

brew desc --eval-all -s unicode and other permutations (except brew --eval-all desc -s ..., I guess) should have succeeded.

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

See above.
MikeMcQuaid commented 10 months ago

Thanks @jwodder for the issue.

I agree that all the --eval-all handling is a bit of a mess. I think ideally brew search (and anything else) should only need --eval-all when evaluating non-Homebrew organisation formulae and just default to core formulae by default.

If/when we're using the JSON API: it shouldn't be needed at all.

CC @Homebrew/maintainers and @Homebrew/security for any thoughts on how this should/should not be working to best balance security and usability.

bevanjkay commented 10 months ago

Just noting that this does currently work only for casks if you also pass --cask, so there's some inconsistency in the handling.

p-linnane commented 10 months ago

I agree that all the --eval-all handling is a bit of a mess. I think ideally brew search (and anything else) should only need --eval-all when evaluating non-Homebrew organisation formulae and just default to core formulae by default.

Strongly agree with this.

MikeMcQuaid commented 10 months ago

Just noting that this does currently work only for casks if you also pass --cask, so there's some inconsistency in the handling.

@bevanjkay can you elaborate a bit more there, not sure I fully understand. Thanks ❤️

bevanjkay commented 10 months ago

At present, if you run the command brew search --desc --eval-all test you will see the error above.

However if you also pass the --cask flag it will allow the search for casks only, without the error.

With --cask you cannot search --desc without --eval-all, but adding the --eval-all flag allows the search to succeed.