MacPorts upgrade after OS X upgrade

Tags mac how-to


After upgrading from one major macOS version to another (such as macOS 10.15 to macOS 11) on a system with MacPorts installed, you will need to migrate MacPorts to the new version.  If you don't want to migrate, you can always uninstall MacPorts entirely before manually reinstalling ports.


  • macOS
  • MacPorts


Installing or modifying installed ports requires an administrator account. If you do not have an admin account on the computer, please send an email to to have MacPorts migrated.
On macOS 10.13 the result of running this command may state either that the command line tools are already installed or that they cannot be found in the System Update list. If that occurs, proceed with the following steps. The re-installation of the ports will still work.
  1. Upgrade XCode Tools: sudo xcode-select --install
  2. Download and run the latest MacPorts installer for your OS.
  3. Save the list of installed ports: sudo port -qv installed > myports.txt
  4. Remove the +gcc49 variant from all ports in myports.txt: sed 's/+gcc49//' myports.txt
  5. Uninstall all installed ports: sudo port -f uninstall installed
  6. Clean any partially-completed builds: sudo rm -rf /opt/local/var/macports/build/*
  7. Download and execute the restore_ports script:
    1. curl --location --remote-name
    2. chmod +x restore_ports.tcl
    3. sudo ./restore_ports.tcl myports.txt
  8. If installing a port fails, an error log will be specified. Look into the log file for information about what caused the halt.
  9. If you are unable to remedy the issue and get the installation started back up, please email for assistance.
On macOS 10.13, the following message may appear:
Warning: The Xcode Command Line Tools don't appear to be installed; most ports will likely fail to build.
Warning: Install them by running `xcode-select --install'.
The ports should still install correctly despite this, and running xcode-select --install will likely either state that the command line tools are already installed or cannot be found in the System Update list.

Additional notes


Article ID: 1825
Wed 5/27/20 11:23 AM
Tue 1/11/22 2:32 PM