21

How can one find out the name of the port given a file name, more concretely an executable?

Macport website does not seem to help as you can only search by title and little more.

Thanks!

3
  • 1
    Which executable in particular are you looking for? Maybe I have it installed or know the port that contains it.
    – neverpanic
    Commented Aug 23, 2014 at 9:09
  • 1
    None in concrete... I found the one I was looking for eventually but this is the third time that I needed to know how to and I though should find out. Commented Aug 23, 2014 at 15:33
  • related (the reverse): Listing all files installed by some MacPorts package
    – michael
    Commented Aug 6, 2021 at 8:01

1 Answer 1

32

Unfortunately MacPorts currently (2.3.1) only supports that if you have the port installed, i.e. if you want to find out which port installed a file on your system. In this case, you can use port provides </full/path/to/filename>.

If you are looking for a port to install using an executable name, you're out of luck – MacPorts doesn't have the required databases to do that.

What I usually do instead is search for the file in a Linux distribution, e.g. using apt-file search <filename> on Debian. Given the Debian package name, I search for a similar MacPorts port.

Update 2022-11-30: MacPorts now has a web application available at https://ports.macports.org/search/, which can do this. Use the "File installed" search box in the left sidebar.

Note the documented limitations of this search:

The application fetches data for installed files from the buildbot every time a port is built. The application does not have information about the ports which have never been built since its inception.

This filter searches for the files in the most recent successful build of a port, if available in application database.

1
  • 1
    Sort of complementary information: there exists a program called pkgutil (at /usr/sbin/pkgutil) that prints information about files of macOS's own installed packages. pkgutil could possibly be used to find out how a file was installed. More details: superuser.com/a/891702/199930
    – 0 _
    Commented May 30, 2021 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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