MacOS – Both Safari and Webkit crash on startup

macossafari

I'm trying to debug a Webkit problem, and I seem to have botched my Safari installation: whenever I try to launch any version of Safari or Webkit, it crashes immediately with an error like this:

Dyld Error Message:
Library not loaded: /System/Library/PrivateFrameworks/WebKit2.framework/Versions/A/WebKit2
Referenced from: /System/Library/StagedFrameworks/Safari/Safari.framework/Safari
Reason: image not found

I wasn't able to reproduce my bug in my installed Safari (6.0.5 on Mountain Lion (10.8.4)) but I was on the Webkit nightly I downloaded and installed (r151773).

I was trying to pinpoint the Webkit revision where this became a problem, so I downloaded several more older nightlies, but when I tried launching any of those, they failed to launch with the error above. When I went back to the newer nightly, then to my original Safari, those were all showing the error as well.

I can't find an installer to reinstall Safari 6.0.5. In this answer I found a route to download and install a developer build of Safari 6.1, but that also fails to launch with the same error.

How can I restore my Safari? And, once I get Safari back, is there a way to try several nightlies of Webkit so I can narrow down the scope of the change which created my problem?

Best Answer

You could try doing an upgrade install of OS X from the recovery partition. It should replace preinstalled frameworks and applications with the initial versions but keep user files and settings in place. I have done it twice so far and it solved multiple issues both times, so I have started to recommend it as a troubleshooting step here, even though no-one ever does it.

Another way to restore the directories for Safari or frameworks might be to copy them from a VM.