Skip to main content

Complete re-install of MacPorts - Knowledgebase / Data processing and analysis software resources - ESO Operations Helpdesk

Complete re-install of MacPorts

Authors list

The official guide to migrating/updating MacPorts after a major macOS upgrade is described here:

Alternatively the following resents a step-by-step guide to make a complete reinstall.

First make sure you are using the bash shell:


The following command creates a list of all the packages you requested in your current installation, which you can use after re-installing the MacPorts system to re-install all those packages again. If you prefer to start over from a fresh MacPorts installation, you don't need to do this:

/opt/local/bin/port list requested | awk '{print $1}' | sort -u > $HOME/requested_ports.txt

The command above may fail depending on the “compatibility” of the “old” MacPorts installation under the new macOS installation, ideally it should be done before upgrading the OS.

Next do:

sudo chflags -R noschg,nouchg \
     /opt/local/ \
sudo rm -fr \
     /opt/local/ \
     /Applications/MacPorts \
     /Library/LaunchAgents/org.macports* \
     /Library/LaunchDaemons/org.macports.* \
     /Library/Java/JavaVirtualMachines/openjdk* \
     /Applications/DarwinPorts \
     /Library/Receipts/DarwinPorts*.pkg \
     /Library/Receipts/MacPorts*.pkg \
     /Library/StartupItems/DarwinPortsStartup \
     /Library/Tcl/darwinports1.0 \
     /Library/Tcl/macports1.0 \
     /Library/LaunchDaemons/org.freedesktop.dbus.*.plist \
     ~/.macports rm ~/.macports

It may be necessary to remove /opt/local with the Finder.

Now reinstall with:

cd /tmp
OSname=$(sw_vers -productVersion | sed \
    -e 's/^14\..*/Sonoma/' \
    -e 's/^13\..*/Ventura/' \
    -e 's/^12\..*/Monterey/' \
    -e 's/^11\..*/BigSur/' \
    -e 's/^10\.15\..*/Catalina/' \
    -e 's/^10\.14\..*/Mojave/' \
    -e 's/^10\.13\..*/HighSierra/' \
    -e 's/^10\.12\..*/Sierra/' \
    -e 's/^10\.11\..*/ElCapitan/' \
    -e 's/^10\.10\..*/Yosemite/' \
    -e 's/^10\.10\..*/Mavericks/' \
    -e 's/^10\.10\..*/MountainLion/' \
    -e 's/^10\.10\..*/Lion/' \
    -e 's/^10\.10\..*/SnowLeopard/' \
    -e 's/^10\.10\..*/Leopard/' \
    -e 's/^10\.10\..*/Tiger/' \
    -e 's/^10\.10\..*/Panther/' \
    -e 's/^10\.10\..*/Jaguar/' \
    -e 's/^10\.1\..*/Puma/' \
    -e 's/^10\.0\..*/Cheetah/' \

And then

MPpkg=$(curl -s \
    | grep browser_download_url.\*${OSname}.pkg\" \
    | egrep -v '\-rc[0-9]*\-'\|'\-beta[0-9]*\-' \
    | head -n 1 | awk '{print $2}' | sed -e 's/"//g'\
curl -LO ${MPpkg}
sudo installer -pkg $(basename "${MPpkg}") -target /.
sudo /opt/local/bin/port selfupdate

Then to install the ESO MacPorts Repository:

curl -O
sudo /opt/local/bin/port install
sudo /opt/local/bin/port sync

Then to re-install all the packages you had before:

sudo /opt/local/bin/port install $(cat $HOME/requested_ports.txt)