Repairing “org.eclipse.mylyn.tasks.ui” Eclipse start-up freeze on Mac OSX

Excuse the shameless “fishing for a search string” title, but it just took me over an hour to find a fix for this so, so I’m paying it forward.

The problem

This issue appears as you start Eclipse after an incomplete shutdown on a previous session – i.e. if it was force closed. If you search for this problem you’ll see a lot of sledgehammer fixes suggested:

“Delete your workspace and reimport your projects.”

“Delete your metadata directory and reimport.”

“Delete all of the hidden files in your workspace.”

etc.

The very worst recommends completely removing Eclipse and starting again. To be clear DO NOT DO ANY OF THESE! The solution is far too aggressive, and it loses your workspace configuration settings.

The problem occurs because Eclipse quits before it is able to delete a hidden “.lock” file in the workspace metadata. Upon restart it scans the metadata and sees this lock file, and as there is no pending task to clear it in the current instance, it awaits a deletion that will never happen.

The fix

Force quit Eclipse from the Dock if it’s still hanging; the damage is done, you can’t make it worse by closing it.

Open up Terminal, and navigate to the folder that contains your Eclipse workspace, then use this line to remove the hidden file lock.

sudo rm workspace/.metadata/.lock

Next, launch Eclipse with the clean and refresh arguments, so that the instance knows to regenerate any metadata that looks weird.

cd /Users/YOUR USER NAME/Development/eclipse/Eclipse.app/Contents/MacOS
./eclipse -clean -refresh

That’s it!

If you think that this might happen a lot (or if you’re just really into scripting for fun… What?) you can record the above actions as an automator script, and create a shortcut to it in your Eclipse folder so you can quickly repair the problem again in future.

The credit for finding this fix should go to sulai on StackOverflow.com, as I learnt about it from his comment on this thread, so do head over there and up-vote their answer if it helps you.