18 | | 1. [=#xcode **Install the latest version of Xcode and the Xcode command-line tools**] |
| 17 | 1. [=#xcode **Install the latest version of Xcode and/or the Xcode command-line tools**] |
| 18 | |
| 19 | If you have Xcode installed, [https://guide.macports.org/#installing.xcode upgrade it to the latest version] that is compatible with your OS. |
| 20 | Open the Xcode application once after installation and follow any prompts. |
| 21 | |
| 22 | 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. |
| 23 | |
| 24 | 2. [=#config **Review macports.conf settings**] |
| 25 | |
| 26 | 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. |
| 27 | |
| 28 | 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. |
| 29 | |
| 30 | 3. [=#portmigrate **Run port migrate**] |
| 31 | {{{ |
| 32 | sudo port migrate |
| 33 | }}} |
| 34 | 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. |
| 35 | |
| 36 | 4. [=#managesnap **(Optional) Managing migration snapshots**] |
| 37 | |
| 38 | `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: |
| 39 | {{{ |
| 40 | sudo port restore --last |
| 41 | }}} |
| 42 | |
| 43 | 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 |
| 44 | {{{ |
| 45 | sudo port snapshot --delete <ID> |
| 46 | }}} |
| 47 | replacing `<ID>` with the ID number of the snapshot you want to delete. |
| 48 | |
| 49 | == Old Migration procedure == |
| 50 | |
| 51 | 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. |
| 52 | |
| 53 | 1. [=#xcode-old **Install the latest version of Xcode and the Xcode command-line tools**] |