Replace non-functioning system applications Yesterday I used Drive Genius 3 to clear up some space on my primary drive. I may have been a bit too aggressive, allowing it to delete localizations and a few other things. Long story short, apps like App Store, Preview, TextEdit and Terminal would no longer open. Clicking on the dock icon it would light up for a second and then immediately fizzle out. Opening Console, I saw things like this:


  Terminal[728]: Unable to load nib file: MainMenu, exiting
  com.apple.launchd.peruser.501[211]: (com.apple.Terminal.60048[728]) Exited with code: 1
  
  TextEdit[724]: Unable to load nib file: Edit, exiting
  com.apple.launchd.peruser.501[211]: (com.apple.TextEdit.58816[724]) Exited with code: 1
  librariand[255]: client process 724 does not have a valid com.apple.developer.ubiquity-container-identifiers entitlement
  error in handle_container_path_request: LibrarianErrorDomain/9/The client process does not have a valid com.apple.developer.ubiquity-container-identifiers entitlement


This was not a user-based or permissions-based problem, as I tried logging in as an existing user, and created a new user and logged in as them as well, both of which experienced the same issue.

So thank you, Drive Genius, and next time I'll be a lot more careful. In the meantime, I needed to figure out how to get these applications running again. I saw suggestions out there to use things like Pacifist to extract the original application files, but that only seemed to apply if you have original media, which we don't get anymore. And I'd have downloaded the software from the App Store, but catch-22, I couldn't open the App Store...
Luckily, I had another system at the exact same OS level (this is important), which was working fine. I copied the following apps from that machine to a basic folder on the broken machine:

App Store.app
Terminal.app
Preview.app
TextEdit.app


Of course OS X won't let you copy those apps directly into the Applications folder, so I did this, which recursively copies all of the contents (since the .app files aren't just files) and replaces the existing, non-functioning copies:

cp -R ~/&lt;folder&gt;/&lt;file&gt;.app /Applications/


You may have to really ask for a sandwich:

sudo cp -R ~/&lt;folder&gt;/&lt;file&gt;.app /Applications/


And joy, my system works again (but I haven't deleted the copies yet, just in case). 

Hope it helps someone else.