Originally Posted By: artie505
Too bad my idea didn't help. (Actually, I'm not enough of a UNIX guy to have even the vaguest idea whether the command you ran is the correct one, so I'll bow to ganbustein's not having called you out.)

Sorry, artie. I should have scrutinized the command more carefully. It's an unusual variant, in that it uses the find command to locate the lsregister executable instead of typing out its path explicitly, but it should work. Except for the smart quotes. (The command line uses only dumb quotes.) I'm currently running OS X 10.9.5 Mavericks, but I can ssh into a machine running OS X 10.6.8 Snow Leopard, and when I paste in the command with smart quotes I get beeps and a garbled command. If I press return to run the command anyway, I get an error message. I assumed the quotes got smartened when you posted the command here, and were properly dumb when pasted into Terminal. Testing again, I see that it's ssh that doesn't like the smart quotes. If I walk over to my Snow Leopard machine and type them in there, with smart quotes, the command runs with no errors but does nothing.


But it doesn't matter. I found the problem, and it isn't the Launch Services database.

It turns out that ~/Library/Preferences isn't the only folder that contains a file named com.apple.Finder.plist. There is another file with that name in /System/Library/LaunchAgents.

This file is the one that tells the system to launch Finder on each login, and to restart it every time it crashes. It tells the system that it's the job whose name is "com.apple.Finder". Other things (like Dock, for example) that want to launch Finder do it using its job name, not the path to its executable.

To test what would happen if that file were trashed (and not trash my own system in the process), I simulated its effect by entering the following command on my Snow Leopard machine:

launchctl unload /System/Library/LaunchAgents/com.apple.Finder.plist

This command uses launchctl to tell the launch daemon (launchd) to temporarily forget that it ever saw the file in question. Without the -w flag, this is temporary amnesia. The file would be seen normally on the next login. (Like I said, I didn't want to hose my own system.) launchd obligingly quits Finder for me. (The first time I tried this, I first quit Finder explicitly with:

osascript -e 'tell application "Finder" to quit'

but it turns out that was unnecessary.)

But now the system is (temporarily) in the same state it would be in if the file had been missing at login. Finder is not running, and launchd knows nothing about any such job as "com.apple.Finder".

Dock is running, and still shows a Finder icon. When I click on that icon, I get a dialog saying:

The application Finder.app can't be opened.
-10810

Sound familiar?

I put my system back in working order with

launchctl load /System/Library/LaunchAgents/com.apple.Finder.plist

but a simple logout/login would have sufficed, since the file itself was not touched.


To restore your system, you need to restore this file. On OS X 10.6.8, it should look like:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>RunAtLoad</key>
	<false/>
	<key>KeepAlive</key>
	<dict>
		<key>SuccessfulExit</key>
		<false/>
		<key>AfterInitialDemand</key>
		<true/>
	</dict>
	<key>Label</key>
	<string>com.apple.Finder</string>
	<key>Program</key>
	<string>/System/Library/CoreServices/Finder.app/Contents/MacOS/Finder</string>
	<key>ThrottleInterval</key>
	<integer>0</integer>
</dict>
</plist>



At this point, you may have the correct file in ~/Library/Preferences. You can look by entering the command:

cat ~/Library/Preferences/com.apple.Finder.plist

If it looks like the above, you can put it back in place with:

sudo mv ~/Library/Preferences/com.apple.Finder.plist /System/Library/LaunchAgents

If you haven't used the sudo command before, you'll get a scary warning message. You have been warned! sudo is a powerful command. But we need its power now, so proceed by entering your login password. (Only an admin user can use sudo, but you've already told us you only have one user, so it must be an admin.) Nothing will echo back to your screen while you type, so you need to enter the password blind.

The file probably has the wrong owner by now. The following commands will make sure permissions and ownership are correct:

cd /System/Library/LaunchAgents
sudo chmod 644 com.apple.Finder.plist
sudo chown root:wheel com.apple.Finder.plist


Restart your computer, and all should be well.


That's assuming we can still find the proper plist in your preferences folder. Trouble is, you probably have deleted it by now. You say you have a Time Machine backup, and we can probably get the file from there. We're hampered by the fact that TM's normal restore process uses Finder to browse your backup, and we don't have Finder. I could give you Terminal commands to search your backup for the file, but I don't know if it's on a local disk or on a Time Capsule or somewhere else, and the commands are different.

Instead, the simplest option is probably to just paste it in. I've shown you above what the contents of the file should be. Copy that, then execute the command:

pbpaste > ~/Library/Preferences/com.apple.Finder.plist

and now you have it in your preferences folder. Follow the previous instructions to put it where it belongs in LaunchAgents.

(As you may have guessed from that, I'm a mathematician at heart. We like to turn new problems into old already-solved problems.
  • Q: You have a pan of water on the floor, a match, and an unlit stove. How do you boil the water?
  • A: You put the pan on the stove and use the match to light the stove.
  • Q: You have a pan of water on an unlit stove, and a match. How do you boil the water?
  • A: Put the pan on the floor. You now have a previously solved problem.
  • Q: How do you kill a purple elephant?
  • A: Shoot it with a purple elephant gun.
  • Q: How do you kill a pink elephant?
  • A: Squeeze it by the trunk until it turns purple, then shoot it with a purple elephant gun.
By these questions do you recognize a mathematician.)

Originally Posted By: artie505
Despite your DOS command line background, your acclimation to Terminal is pretty impressive for a Mac newbie, many, if not most, of whom run from Terminal like the plague.

Agreed. Your quick uptake certainly made my job easier.