I recently upgraded my iMac to Mountain Lion and like a bunch of people had a fairly annoying issue where certain things just crashed. In fact pretty much the first thing I did was try to add a Twitter account though System Preferences. It was all fine until I hit the button to add the account but I just got the Spinning Beachball of Death. I tried again – same.

So, I thought to myself – “I’ll just get a Twitter client from the App Store”. Freeze, Spinning Beach Ball of Death. Annoying but not the end of the world I thought. Surely when the first update to Mountain Lion comes out it will be fine. It wasn’t.

Anyway, after a whole hell of a lot of Googling and random attempts to fix this by verifying my user permissions, using recovery mode and a load of other stuff I finally (by pure chance) found a fix 🙂

I had come across a tool called EtreCheck which scans your Mac and tells you what things have and haven’t loaded properly. I had also noticed that a recurrent error was being shown in the logs for a problem with Core Data writing to a persistent store and a repeat crash of Accountsd. I noticed that “Accountsd.plist” was featuring pretty heavily on the EtreCheck list so this looked like a potential culprit.

Googling for “Accountsd” didn’t give me much to go on but when I looked for “corrupted user” I found this: https://discussions.apple.com/message/19338503#19338503

This described my problem exactly and it worked!

The problem was that for some unknown reason the “Accounts” folder hadn’t been created in “~/Library” so whenever an accounts process tried to save some data it couldn’t find or create the SQLite database. To fix this you just need to change a few permissions, run an accounts action to create the file and then reset the permissions with the folder and SQLite file in place.

So, first change the permissions to clear the “immutable” flag by opening a terminal window and typing:

chflags nouchg ~/Library

Then add a twitter account, open the app store or whatever you want to do.

Then, reset the permissions on ~/Library with:

chflags uchg ~/Library

Tada! Fixed 🙂