ShanZhengYang
ShanZhengYang

Reputation: 17621

How to uninstall macports without doing a migration?

I'm currently using MacOS High Sierra 10.13.5. I would like to uninstall MacPorts on my macbook.

Based on the instructions here:

https://guide.macports.org/chunked/installing.macports.uninstalling.html

I should do the following

$ sudo port -fp uninstall installed

Here is the response I see:

Error: Current platform "darwin 17" does not match expected platform "darwin 16"
Error: If you upgraded your OS, please follow the migration instructions: https://trac.macports.org/wiki/Migration
OS platform mismatch
    while executing
"mportinit ui_options global_options global_variations"
Error: /opt/local/bin/port: Failed to initialize MacPorts, OS platform mismatch

Do I really need to do a migration first before uninstalling? Is there a way to install directly now?

Upvotes: 1

Views: 2083

Answers (2)

neverpanic
neverpanic

Reputation: 2998

While the vast majority of files are installed in /opt/local, /Applications/MacPorts or /Library/LaunchDaemons/org.macports.*, there are a few ports that install files in other locations, e.g. due to operating system requirements. Depending on whether or not you had such ports installed, the solution by Ken (https://stackoverflow.com/a/50670316/2127896) may leave some files behind.

If you want to make sure that you caught all files, follow the MacPorts migration instructions until step 3, i.e. basically reinstall MacPorts base (for example by running the installer). This should only take a couple of minutes.

Then, follow https://guide.macports.org/#installing.macports.uninstalling, i.e. run

$ sudo port -fp uninstall installed

and then the rm -rf command already mentioned in Ken's answer.

Upvotes: 2

Ken Thomases
Ken Thomases

Reputation: 90521

The vast majority of MacPorts-installed stuff goes into /opt/local. You can, of course, delete that using:

sudo rm -rf /opt/local

I know of a couple of ports which install stuff into /Applications/MacPorts, so you could also do this to catch that stuff:

sudo rm -rf /Applications/MacPorts

I have one port which has installed a launch daemon in /Library/LaunchDaemons, so:

sudo rm -rf /Library/LaunchDaemons/org.macports.*

You could check similar places like /Library/LaunchAgents and the corresponding directories in ~/Library.


Actually, the link you provided in your question tells you what to do:

$ sudo rm -rf \
        /opt/local \
        /Applications/DarwinPorts \
        /Applications/MacPorts \
        /Library/LaunchDaemons/org.macports.* \
        /Library/Receipts/DarwinPorts*.pkg \
        /Library/Receipts/MacPorts*.pkg \
        /Library/StartupItems/DarwinPortsStartup \
        /Library/Tcl/darwinports1.0 \
        /Library/Tcl/macports1.0 \
        ~/.macports

Upvotes: 1

Related Questions