Skip to content

Instantly share code, notes, and snippets.

@fakerybakery
Last active September 10, 2023 22:21
Show Gist options
  • Save fakerybakery/79aac397fda1db3935b63d29305fc83c to your computer and use it in GitHub Desktop.
Save fakerybakery/79aac397fda1db3935b63d29305fc83c to your computer and use it in GitHub Desktop.
How to (really) uninstall MacPorts

How to (really) uninstall MacPorts (macOS ONLY)

Ready to ditch MacPorts? Here's how to (really) do it:

If you follow the MacPorts Uninstallation Guide, which I really recommend you try first, you may encounter the following error:

zsh: no matches found: ...

So here's how (really) uninstall MacPorts (sudo access required):

/bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/fakerybakery/79aac397fda1db3935b63d29305fc83c/raw/82edc0175f3200481e4715dbdbbfa6a4f4021f10/uninstall_macports.sh)"

Curious? Check out the source of the script below!

License: CC-BY-NC-ND

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

echo "Welcome to the Complete MacPorts Uninstaller, the #1 way to DITCH MACPORTS! License: CC-BY-NC-ND"
sleep 1
echo "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
sleep 1
read -p "Ready to ditch MacPorts? Are you sure? (Y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "These steps may take a while and not show progress indicators. Please be patient."
sleep 2
echo "Don't worry if you get some (Invalid Path, command not found, etc) errors. You can ignore these."
sleep 2
echo "Step 1: Uninstall all existing MacPorts"
sleep 1
sudo port -fp uninstall installed
echo "Step 2: Remove MacPorts users and groups"
sleep 1
sudo dscl . -delete /Users/macports
sudo dscl . -delete /Groups/macports
echo "Step 3: Remove the rest of MacPorts"
sleep 1
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"
echo "Congrats! You have ditched MacPorts! Optional: Restart your computer to remove caches."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment