Monday 7 November 2016 — This is eight years old. Be careful.
The Mac is a nice machine and operating system, but there’s one part of the experience I don’t understand: software installation and uninstallation. I’m sure the App Store is meant to solve some of this, but the current situation is oddly manual.
Usually when I install applications on the Mac, I get a .dmg file, I open it, and there’s something to copy to the Applications folder. Often, the .dmg window that opens has a cute graphic as a background, to encourage me to drag the application to the folder.
Proponents of this say, “it’s so simple! The whole app is just a folder, so you can just drag it to Applications, and you’re done. When you don’t want the application any more, you just drag the application to the Trash.”
This is not true. Applications may start self-contained in a folder, but they write data to other places on the disk. Those places are orphaned when you discard the application. Why is there no uninstaller to clean up those things?
As an example, I was cleaning up my disk this morning. Grand Perspective helped me find some big stuff I didn’t need. One thing it pointed out to me was in a Caches folder. I wondered how much stuff was in folders called Caches:
$ sudo find / -type d -name '*Cache*' -exec du -sk {} \; -prune 2>&-
(Find every directory with ‘Cache’ in its name, show its disk usage in Kb, and don’t show any errors along the way.) This found all sorts of interesting things, including folders from applications I had long ago uninstalled.
Now I could search for other directories belonging to these long-gone applications. For example:
$ sudo find / -type d -name '*TweetDeck*' -exec du -sh {} \; -prune 2>&-
12K /Users/ned/Library/Application Support/Fluid/FluidApps/TweetDeck
84K /Users/ned/Library/Caches/com.fluidapp.FluidApp.TweetDeck
26M /Users/ned/Library/Containers/com.twitter.TweetDeck
1.7M /Users/ned/Library/Saved Application State/com.fluidapp.FluidApp.TweetDeck.savedState
$ sudo find / -type d -name '*twitter-mac*' -exec du -sh {} \; -prune 2>&-
288K /private/var/folders/j2/gr3cj3jn63s5q8g3bjvw57hm0000gp/C/com.twitter.twitter-mac
99M /Users/ned/Library/Containers/com.twitter.twitter-mac
4.0K /Users/ned/Library/Group Containers/N66CZ3Y3BX.com.twitter.twitter-mac.today-group
That’s about 128Mb of junk left behind by two applications I no longer have. In the scheme of things, 128Mb isn’t that much, but it’s a lot more disk space than I want to devote to applications I’ve discarded. And what about other apps I tried and removed? Why leave this? Am I missing something that should have handled this for me?
Comments
Some files you don't want to clean up, for example configuration. What if you were just uninstalling on the way to installing a new version, and poof there goes your vimrc? Not what you want. But caches are a different story.
I looked around the filesystem hierarchy standard to see if there's anything where packages get a designated area in (for example) /var to put per-user files. The only one that jumps out is /var/mail. A program might put a shared cache in /var/cache but per-user caches aren't mentioned, and using homedirs is a lot safer from a security standpoint.
By the way, you might rather use 2>/dev/null than 2>&-. There are a couple problems with closing stderr:
(1) the program might terminate early because it can't output stderr (but you don't know because it can't give you an error message) (2) the program might open a file, get FD 2, and then try to write to stderr and accidentally write to the file. This doesn't demonstrate with Python because Python's open() skips FD 2 even if it's available. But not everything is Python. ;-)
What you should delete or keep after an uninstall is one of those unsolvable problems since we don't have "why are you uninstalling" the result is a compromise of things we want to delete since they are no longer needed and things that would be nice to not have to reconfigure if you install again.
It's almost like what car settings do you lose when the battery is flat? What's okay and what is annoying.
@Aron: thanks, i never really understood what 2>&- did!
Add a comment: