Uninstalling packages on Mac OS X


Here is a small  HOWTO for  uninstalling Mac OS X Installer flat packages using native pkgutil.

Getting a list of the installed packages, which contain the application name:

$ pkgutil --pkgs | grep the-application-name

If you found the package name you are looking for, let’s get info and the list of installed files for this package:

$ pkgutil --pkg-info the-package-name.pkg
$ pkgutil --files the-package-name.pkg

After visually inspecting the list of files you can do something like:

$ cd / # assuming the package is rooted at /...
$ pkgutil --only-files --files the-package-name.pkg | tr '\n' '\0' | xargs -n 1 -0 sudo rm -i
$ pkgutil --only-dirs --files the-package-name.pkg | tail -r | tr '\n' '\0' | xargs -n 1 -0 sudo rmdir

Needless to say,  extreme care should always be taken when removing files with root privileges. Particularly, be aware that some packages may update shared system components, so uninstalling them can actually break your system by removing a necessary component.

For smaller packages it is probably safer to just manually remove the files after visually inspecting the package file listing.

Once you’ve uninstalled the files, you can remove the receipt with:

$ sudo pkgutil --forget the-package-name.pkg

For more details, see the pkgutil man page.

I’ve used materials from https://wincent.com/wiki/Uninstalling_packages_(.pkg_files)_on_Mac_OS_X.


Leave a Reply

Your email address will not be published. Required fields are marked *