Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find package for installed file in Brew?

Tags:

homebrew

How can I identify the package/formula for a given file, or a listing of all of a package's owned files, in Homebrew?

like image 899
Dustin Oprea Avatar asked Nov 11 '13 20:11

Dustin Oprea


People also ask

Where are brew packages installed Mac?

Homebrew put installations files at the user path /usr/local/bin/ , or in the file system in /usr/local/Cellar , but links them into /usr/local/bin . This facilitates for you to launch these apps from the applications folder as if it is a usual part of your lovely macOS.

How do I find Homebrew packages?

brew search <search term> will list the possible packages that you can install. brew search post will return multiple packages that are available to install that have post in their name. brew info <package name> will display some basic information about the package in question.

Where are brew packages installed Linux?

The installation script installs Homebrew to /home/linuxbrew/. linuxbrew using sudo if possible and within your home directory at ~/. linuxbrew otherwise. Homebrew does not use sudo after installation.

How do I install a specific package with brew?

Installing the latest package: Easy Installing with brew can't be made any simpler. Search the package you need, type brew install <package-name> , and that's all.


2 Answers

To see all files in a package:

brew ls <package> 

To find the package for a file, look at the file like this:

ls -l /usr/local/bin/whatever 

If it was installed by Homebrew, it will be a symlink into /usr/local/Cellar/something, so that will tell you what package it's from.

like image 145
Peter Eisentraut Avatar answered Oct 08 '22 22:10

Peter Eisentraut


Just wrote this dirty function to get you the brew package name a file belongs to:

function brew_find_pkg {     file_to_search="$@"      for package in $(brew list); do         brew ls $package | grep -E -q "/${file_to_search}$"         if [ $? -eq 0 ]; then             echo $package             break         fi     done } 

Just type that in the terminal. And then to find to find the brew package a file belongs to, say the file gsed, just call the function like this

brew_find_pkg gsed 

Note that the function will not work if you provide the full path of the file.

like image 24
GMaster Avatar answered Oct 08 '22 22:10

GMaster