Jay Taylor's notes

back to listing index

macos - How to get Brew formula from the filename of installed binary? - Ask Different

[web search]
Original source (apple.stackexchange.com)
Tags: howto tools homebrew macOS binaries bin executables locating whence apple.stackexchange.com
Clipped on: 2023-12-13

Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.

Sign up to join this community
Image (Asset 1/20) alt= It is not part of Homebrew proper but you can inspect the code yourself.

answered Apr 4, 2020 at 13:36
Synoli
1,25188 silver badges1414 bronze badges
  • 1
    Not a user of Homebrew as I prefer MacPorts, but this is really cool. +1
    – Allan
    Apr 5, 2020 at 5:27
  • 1
    Thank you. So, basically what your command does, is to go into /usr/local/bin, search for a symlink matching the supplied filename, follow the symlink into /usr/local/Cellar to get the name of the formula that's in the absolute path, e.g.: /usr/local/bin/ragg2@ -> ../Cellar/radare2/4.3.1/bin/ragg2?
    – Shuzheng
    Apr 5, 2020 at 5:33
  • @Shuzheng Mostly, yes. It also honors /usr/local/sbin, and I plan to add support for Cask- and npm-installed executables.
    – Synoli
    Apr 5, 2020 at 19:30
  • 1
    You may also want to check out github.com/Homebrew/homebrew-command-not-found. It provides a brew which-formula command, which may support not-yet-installed packages, too. (I didn’t know it existed until after I wrote brew whence.)
    – Synoli
    Apr 5, 2020 at 19:34
  • brew whence does not work for the keg-only llvm formula. The "comes from" column is blank. brew whence /usr/local/opt/llvm/lib/libc++.a /usr/local/opt/llvm/lib/libc++.a (not a link)
    – strager
    Jan 13, 2021 at 9:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .

Hot Network Questions

more hot questions
Ask Different
Company

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. rev 2023.12.13.2565

Apple is a trademark of Apple Inc., registered in the US and other countries. This site is not affiliated with or endorsed by Apple Inc. in any way.