MacPorts upgrade after OS X upgrade

Tags mac how-to

Objective

After upgrading from one major macOS version to another (Such as 10.11 to 10.12) on a system with MacPorts installed, you need to migrate MacPorts to the new version.

Environment

  • macOS
  • MacPorts

Procedure

 Note
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 lsait@umich.edu to have MacPorts migrated.
 Note
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 https://github.com/macports/macports-contrib/raw/master/restore_ports/restore_ports.tcl
    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 lsait@umich.edu for assistance.
 Note
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

Details

Article ID: 1825
Created
Wed 5/27/20 11:23 AM
Modified
Tue 6/23/20 11:36 AM