wiki:Migration

Migrating MacPorts after a major operating system upgrade or from one computer to another

A MacPorts installation is designed to work with a particular operating system and a particular hardware architecture.

This migration procedure ensures a smooth transition after major system changes, such as:

  • major operating system upgrades (e.g., from macOS 13 Ventura to macOS 14 Sonoma).
  • CPU architecture changes (e.g., from Intel to Apple Silicon).

If you don't want to migrate, you can always uninstall MacPorts entirely before manually reinstalling ports.

Note: If you plan to move from one Mac to another Mac using Migration Assistant, you have to do that first before you can use this procedure.

Migration procedure

Note that this procedure requires MacPorts 2.10.0 or later. If you have an older version of MacPorts installed, you will first need to install the current version (this will not affect your installed ports).

  1. Install the latest version of Xcode and/or the Xcode command-line tools

If you have Xcode installed, upgrade it to the latest version that is compatible with your OS. Open the Xcode application once after installation and follow any prompts.

Install the latest version of the command line tools for your OS. (Run xcode-select --install). On some macOS versions, you may need to run Software Update to update the CLTs if an older version is already installed. Some recent versions of macOS have a bug that prevents them from automatically updating the command line tools, so if the preceding command says they're already installed, they may not be up to date and you may need to update manually by following the instructions in ProblemHotlist#reinstall-clt.

  1. Review macports.conf settings

If your macports.conf (typically at /opt/local/etc/macports/macports.conf) contains uncommented settings for universal_archs or build_arch, you will likely want to update them, since newer OS versions may support different CPU architectures. Default values are fine for most users, so unless you know you need something different, just comment out these two lines.

Several other settings in macports.conf have changed their defaults over the years. Take a moment to compare each line of your macports.conf with the corresponding line in macports.conf.default in the same directory. Unless you know a reason why a line in your settings file should be different from the defaults, adopt the line from the defaults file.

  1. Run port migrate
    sudo port migrate
    
    This will reinstall the MacPorts base system for your current system if needed, and reinstall ports that are not compatible with your current system. Any ports that are not able to be reinstalled will be reported at the end.
  1. (Optional) Managing migration snapshots

port migrate takes a snapshot of your installed ports before reinstalling them. If some of your ports failed to reinstall, you may want to try again later after they have been fixed—this can be done by running:

sudo port restore --last

When you no longer need the snapshot, you can delete it to save some disk space. Run port snapshot --list to see the snapshots that exist, and note the ID number in the first column of the output. Then run

sudo port snapshot --delete <ID>

replacing <ID> with the ID number of the snapshot you want to delete.

Troubleshooting

A potential problem comes from possible differences between ports that do compile on an older macOS, but no longer on the newer. For instance, you might have installed OpenBLAS on macOS Mojave. This was built with gcc10, the then preferred version of gcc. OpenBLAS sets a +gcc10 variant for this and it has remained like that as long as you were updating it. When upgrading to macOS Monterey according to the procedure above, MacPorts will try to exactly recreate what was on Mojave, hence OpenBLAS +gcc10. But gcc10 may not compile on macOS Monterey (it does not as I write this example). Hence, the migration of OpenBLAS and everything that depends on it fails.

Another issue may come from incompatibility between some additional components, which may manifest itself with ports failing with a message like

Failure Reason: The version of the CoreSimulator framework installed on this Mac is out-of-date and not supported by this version of Xcode.
Recovery Suggestion: Please ensure that you have installed all available updates to your Mac's software, and that you are running the most recent version of Xcode supported by macOS.

In this case you may be able to solve it by running

xcodebuild -runFirstLaunch

Old Migration procedure

Note that the information below is for the older, more manual Migration procedure. You probably don't need it if you are using MacPorts 2.10.0 or later.

Last modified 2 months ago Last modified on Feb 20, 2025, 9:16:27 PM