macports

Find a macports package given a file name


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!


Solution

  • 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.