Software⏱️ 4 min read📅 2026-06-15

How to Fix: Can't uninstall MacPorts with error "Current platform "darwin 23" does not match expected platform "darwin 22""

MacPorts uninstallation issue due to OS platform mismatch.

Quick Answer: Try reinstalling MacPorts with the --upgrade option, e.g. sudo port install --upgrade macports.

The error 'Current platform "darwin 23" does not match expected platform "darwin 22"' occurs when MacPorts is unable to uninstall itself due to an OS platform mismatch. This issue typically affects users who have upgraded their operating systemwithout properly updating MacPorts, leading to frustration and difficulties in removing the package manager. In this guide, we will walk you through the steps to resolve this issue and cleanly remove MacPorts from your system.

Upgrading XCode and attempting to migrate MacPorts using the provided instructions may not be enough to resolve the issue. This is because the migration process relies on the expected platform version being 'darwin 22', which does not match the actual platform version of 'darwin 23'. The following steps will guide you through a more thorough approach to resolving this error and removing MacPorts from your system.

💡 Why You Are Getting This Error

  • The primary reason for this error is that MacPorts relies on an outdated version of XCode, which is not compatible with the current platform. When upgrading XCode, it may not be enough to update MacPorts to the correct platform version. To resolve this issue, you need to properly migrate MacPorts and update your system to match the expected platform version.
  • An alternative reason for this error could be that there are stale or leftover files from previous installations of MacPorts on your system. This can cause the uninstallation process to fail due to OS platform mismatch. In such cases, a more thorough cleanup of the system may be required.

🔧 Proven Troubleshooting Steps

Migrate and Update System

  1. Step 1: Update XCode to the latest version using the App Store or by downloading the latest version from the official Apple website.
  2. Step 2: Open Terminal and run the command `sudo port migrate` to initiate the migration process. This may take some time depending on the size of your system.
  3. Step 3: After completing the migration process, run `sudo port uninstall --force macports` to remove MacPorts from your system.

Clean System and Reinstall

  1. Step 1: Open Terminal and run the command `rm -rf /opt/local` to delete the entire MacPorts directory.
  2. Step 2: Run `sudo rm -rf ~/Library/Preferences/com.apple.Macports.plist` to remove any leftover configuration files.

✨ Wrapping Up

By following these steps, you should be able to resolve the 'Current platform "darwin 23" does not match expected platform "darwin 22"' error and cleanly remove MacPorts from your system. Remember to update XCode and properly migrate MacPorts if you have upgraded your OS. If the issue persists, consider performing a clean system reinstall and starting fresh with MacPorts.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions