Skip to content

Instantly share code, notes, and snippets.

@uchida
Last active March 1, 2018 16:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save uchida/4632662 to your computer and use it in GitHub Desktop.
Save uchida/4632662 to your computer and use it in GitHub Desktop.
MacTeX uninstaller script based on pkgutil command
#!/bin/bash
# MacTeX uninstaller script based on pkgutil command
# by Akihiro Uchida, CC0 dedicated to the public domain
# see http://creativecommons.org/publicdomain/zero/1.0/
IFS=$(echo -en "\n")
for pkg in $(pkgutil --pkgs|grep org.tug.mactex); do
volume="$(pkgutil --pkg-info "$pkg"|grep volume|cut -d' ' -f2-)"
location="$(pkgutil --pkg-info "$pkg"|grep location|cut -d' ' -f2-)"
echo "remove all of the files installed under the $pkg"
for file in $(pkgutil --files "$pkg"); do
rm -rf "${volume}${location}/${file}"
done
pkgutil --forget "$pkg"
done
echo "remove TeX Distribution pane on the System Preferences.app"
rm -rf /Library/PreferencePanes/TeXDistPrefPane.prefPane
echo "remove items in /Library/TeX"
rm -rf /Library/TeX/.scripts /Library/TeX/Distributions
rm -f /Library/TeX/Documentation /Library/TeX/Local /Library/TeX/Root
Copy link

ghost commented Mar 27, 2016

Are you absolutely and totally sure this removes ALL traces of MacTex? I want to do an absolutely clean reinstall.

@uchida
Copy link
Author

uchida commented Apr 4, 2016

There are no guarantee to remove ALL.
This simply mainly depends on pkgutil(1).
This command use "receipt" database created by installer but installer could locate files not in "receipt" with postinstall script.
And this uninstall script has no update from Jan 27, 2013 and I have never install MacTeX from last update.

@EshanSingh, Uninstalling - MacTeX - TeX Users Group may help.

@uchida
Copy link
Author

uchida commented Apr 4, 2016

You can confirm postinstall scripts If MacTeX installer is available, extract xar -xf mactex-YYYYMMDD.pkg and then *.pkg/Scripts will be available.
postinstall scripts are available in these Scripts, which are tar.gz archives actually.

@robsalasco
Copy link

Thank you @uchida

@grahampugh
Copy link

Warning - this will remove everything in /usr/local!
Use of rm -rf "${volume}${location}/${file}" from pkgutil --files output is very dangerous!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment