This problem has been bugging me for months. I've kept a weather eye on the Google results, poked around trying to find my own solution, upgraded to Yosemite to see if the issue was resolved there, but nothing turned up. So, during the Thanksgiving break I decided to sit down and fix this once and for all.
Looooong story short, every time you add a new tag (and possibly when you add a tag to a file) it gets popped into the Finder sidebar for easy access. Handy. Thing is, if you get crazy and add a metric ton of tags, none of them are ever removed from the Finder sidebar. They roll off the edge where you can't see them, and are flagged as "visible if newer items are removed" but they are all retained in the sidebar items plist. This plist gets massive, and takes a long time to parse any time it must be modified.
To make things worse, when you have "documents and data" turned on under System Preferences → iCloud, the tag list is synced. This means the hang follows you to every machine where you are signed into iCloud, even on a fresh reload of OS X. Funfunfun.
Thankfully, there is an easy fix. I'll keep the explanation simple for Joe Internet who may be having this problem stumble across this post.
When the Finder is running properly (not beach-balled), right-click on the icon in the Dock and select Go to Folder. In the dialog that appears type ~/Library/Preferences/
. That funny little squiggle at the front is just a nice little shortcut that tells the dialog to start in your home folder for the path, rather than the root of the internal drive.
You will be presented with a cornucopia of scary looking plists. The one we are after is titled com.apple.sidebarlists.plist
. Copy that plist somewhere you can find it later (just in case something goes awry and you have to put it back). Now, delete the the original plist in the Library folder and reboot your machine. After the reboot Finder will have an empty tag sidebar and you can create, delete, and rearrange tags to your hearts content. No hangs. As long as you have iCloud "Documents and Data" enabled, this new clean sidebar will also be uploaded to iCloud and clear out the old gigantic one on all your machines.
It should be noted that this DOES NOT delete the tags from your files. That information is actually appended to an extended attribute (xattr) of the file itself, rather than being stored in a single plist or database somewhere. Thankfully, the tags on the files themselves aren't what's causing the hang issue, so we can leave them untouched.
Of course, what you will lose are the list of tags and custom folders you want in the Finder sidebar. Add the folders back the normal way (drag them into the sidebar) and you can select which tags you want by going to the Finder menu → Preferences → Tags and checking the boxes. I've got about a dozen and things are snappy.
One other unfortunate loss are the tags' assigned colors. That's strictly stored in the Finder's plist. The tags may appear to retain their color until you add them back to the sidebar, or try to apply a tag to an item, at which point the color vanishes.
After you've added a tag or two back to the sidebar the "all tags" item will reappear at the bottom of the list. Click on that and scroll through the list of tags to re-assign their colors. Make sure to re-apply color even to the tags that appear to have retained it, because when that tag is next added to a file or otherwise modified there's a good chance the color will disappear.
Something to note if you have a lot of colors applied: adding them all back may cause the hang issue to re-manifest. All those color assignments are stored in the plist, and too many may drag things down. I've only got a few color assignments so I haven't been able to verify this theory.
That's it! Congratulations! Tags are now usable on your machine(s) again. Just remember to go into Finder → Preferences → Tags every now and again and clear the checkbox or minus sign from the tags you don't want displayed in the sidebar and things should remain snappy.
Best Answer
It seems likely that the problem stems from corrupted data on your hard drive. The Finder asks the FileSystem to give it information about the content of the folder and either the Finder fails to properly handle the error returned by the FileSystem or the FileSystem keeps trying endlessly to access the faulty data without properly returning.
In order to make sure it's not simply a Finder bug, check whether you can access the folder fine from a Terminal:
Get Info
.Where:
field, it shows the actual path of the parent folder./Users/your-user-name/Path/To/Parent
command-space
and typeterminal
).cd
(ending space) then paste the copied path. This should look like:cd /Users/your-user-name/Path/To/Parent/problem-folder
cd "/Users/your-user-name/Pa th/T o/Parent"
ls -lR "problem-folder"
replacing the last parameter with the name of the problem folder.Normally this should list the content of the problem folder as well as that of all its subfolders (this should print a lot of text if the folder hierarchy is deep).
Since this completely bypasses the Finder, if this works it means that the bug lies with how the Finder deals with the folder data (for whichever reason). However if the Terminal freezes when running this command, this would really point toward a hard drive issue.
In the latter case I would recommend that you first run Apple's DiskUtility application and attempt to verify the disk:
Disk Utility
).Verify Disk
button.This should take a bit of time and will print a list of possible errors. If there are any issues and/or if the log indicates that you should run a repair on the disk then you should press the
Repair
button. In any case it should not hurt if you choose to repair the disk even if no errors are displayed.If a repair fixes the issue, then this likely indicates that the error was not due to a faulty hard drive but to invalid FileSystem data and you should be good to go again.
However, if the problem persists your hard drive could be the cause of the FileSystem corruption.
In this case I highly recommend to buy a more powerful disk diagnostic and repair program such as DiskWarrior (you will find it at http://www.alsoft.com/diskwarrior/), it is one of the most reputed disk repair program on the Mac.
Update:
If
ls -lR
works correctly, this points to a Finder issue. It could be a buggy QuickLook plugin which is triggered when opening the folder and which has trouble opening some of your files. This does not mean that these files are corrupt.Using the terminal, use the
mv
command to move files to another folder to see if this fixes the issue. For example you could do:mv problem-folder/a* fixa
mv problem-folder/b* fixb
Then try opening each of the
fix
folders to see which ones freeze or not.This way you would be able to identify precisely which file(s) causes the issue if it's caused by a file.
If you have installed Quicklook plugins you might want to try to disable them temporarily to see if that fixes the issue.