Is there a way to figure out which brew package provides a given file (like apt-file on Ubuntu or pkgfile / pacman -F on Arch)?

I'm not talking about querying which locally installed package owns a file on my system, I have a particular file that I need installed (/usr/local/lib/libboost_python.dylib to be specific) and want to know which remote package would provide that file.

  • Turns out that file is provided by boost as long as you configure it with --with-python. Would still be nice to know if there was a way to query which files are provided by which files...
    – mgalgs
    Jul 12, 2014 at 3:58
  • FWIW this is now provided by boost-python instead.
    – Tim Smith
    Jul 2, 2015 at 15:48

5 Answers 5


There is not. Nothing in Homebrew maintains a list of files that a package is allowed or expected to install.


As stated in this answer you can do ls -l /usr/local//lib/whatever and see where the symlink points to.

  • 2
    Or ls -l $(which somecommand)
    – mivk
    Sep 24, 2017 at 12:29

While there is not apt-search like tool that allows one to find public homebrew packages that could provide a file, many brew packages are based on a linux or unix counterpart. You can search the Debian package website to find the needed package.

Example for finding package that provides file goocanvas.pc


Returns libgoocanvas-dev

brew search has no results for libgoocanvas-dev or libgoocanvas but it does have a goocanvas package.

You can define a command ineed as follows that would return a list from debian.org using ineed goocanvas.pc:

ineed() {
echo -en $(echo \
    $(curl -s "https://packages.debian.org/search?suite=default&section=all&arch=any&searchon=contents&keywords=$1") \
       | sed 's%</*tr>%\\n%g') \
    | grep 'class="file"' \
    | sed 's/<[^>]*>//g' \
    | column -t \
    | grep --color -i -w "$1"

Though there isn't a built-in brew command to search for a specific file, you can use a combination of brew list and brew list <formula> to get the answer. It takes a while, but if you're doing some cleanup and have to answer this kind of query more than once, you might do what I have done sometimes: make a catalog of files by package:

# make a catalog of Homebrew-installed packages by package
brew list --formula |\
  while read formula; do
    brew list $formula |\
    while read file; do
      echo -e "$formula\t$file" # need -e to expand \t

If you redirect the output of this script to a file, you can use it to search for the package that provides the file of interest.

  • 2
    This is good, but it searches currently installed packages. The question is asking about searching packages not installed.
    – Burhan Ali
    Mar 31, 2018 at 11:36
  • I like this. FWIW, brew now issues a warning: Warning: Calling brew list to only list formulae is deprecated! Use brew list --formula instead. Dec 21, 2020 at 20:56

Here is the one-liner I have in my bin directory for exactly this purpose:

$ cat ~/bin/brewpkg

which -s $1 ; if [ $? -eq 0 ] ; then ls -lF `which $1` | sed -n 's/^.*\/Cellar\/\([^\/]\{1,\}\)\/.*$/\1/ p' ; fi
  • Downvoting is of course fine. But it is even more fine if it is supported with a comment explaining the reasons.
    – silverdr
    Nov 7, 2021 at 19:53
  • I didn't downvote you, but one limitation of this method is that it only finds executables, and can't identify things that don't have executables, e.g., a python module. Apr 26 at 5:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.