How do I restore /Applications

When trying to copy an application into /Applications, I accidentally copied MyApp.app/Contents into /Applications, turning it into an executable package instead of a folder.

I have removed /Applications/Contents and made the app accessible as it should be (/Applications/MyApp.app/Contents), but /Applications did not revert to its former glory.

Currently, if I navigate to Applications in finder, it opens a terminal into /Applications :(

Edit: I realized Applications is now of type "package". I followed the directions here: http://www.switchingtomac.com/tutorials/how-to-restore-a-folder-that-has-turned-into-a-package-in-os-x/ to no avail.


Solution 1:

OK - this is an odd one. The most straightforward solution would be to use Time Machine to restore /Applications from the backup prior to it becoming marked as a package and not as a folder.

Barring that, You will need to boot into single user mode and delete /Application/Contents and perhaps some other files (it's hard to know what exactly else got messed up) by mounting the filesystem in read/write mode.

 /sbin/mount -uw /
 rm -rf /Applications/Contents
 # and optionally
 mv /Applications /badApplication_package

Alternatively, you could try rebooting with Command R and just reinstalling the OS - hoping that /Applications gets corrected. If you were worried about the rm command, you could also rename /Applications and reinstall your OS - hand moving back just the Apps you need being careful not overwrite things again.

This is a rare problem to face - so congratulations on forcing yourself to learn how packages and apps get made on OS X the hard way.

Solution 2:

/Applications/Contents/ shouldn't normally exist, so it's unlikely that anything was overwritten. It's probably safe to remove it from Terminal:

sudo rm -r /Applications/Contents/