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
    Commented Jul 12, 2014 at 3:58
  • FWIW this is now provided by boost-python instead.
    – Tim Smith
    Commented 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.

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

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.

  • 4
    This is good, but it searches currently installed packages. The question is asking about searching packages not installed.
    – Burhan Ali
    Commented 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. Commented Dec 21, 2020 at 20:56

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"

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
  • 1
    Downvoting is of course fine. But it is even more fine if it is supported with a comment explaining the reasons.
    – silverdr
    Commented 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. Commented Apr 26, 2022 at 5:04

You must log in to answer this question.

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