X

Tackling Launch Service woes in OS X

File/Application association in OS X is done by the system's launch service, which if corrupt can result in odd problems with specifying applications to open your documents.

Topher Kessler MacFixIt Editor
Topher, an avid Mac user for the past 15 years, has been a contributing author to MacFixIt since the spring of 2008. One of his passions is troubleshooting Mac problems and making the best use of Macs and Apple hardware at home and in the workplace.
Topher Kessler
4 min read

When you open a document in OS X, the default application for that file type is used to read the file; however, you may have alternative applications installed for handling the document, which can be accessed from the Open With menu when you right-click the document in the Finder. For instance, a text document may open in TextEdit by default, but if you right-click the document, you may see programs like Pages, Word, TextWrangler, or others you have installed listed as options for opening the document.

These behaviors in OS X for handling documents and applications are done by the system's Launch Services, which is a service that reads a program's capabilities from a small file called "info.plist" within it, and updates the launch services database to include these capabilities. The system has three ways of doing this. The first is if the program is installed using Apple's installer program as opposed to being a drag-and-drop installation, the second is when the program is opened for the first time, and the third is if the launch services are manually updated.

While this is the default behavior in OS X, sometimes you may run into problems with the system either not listing the proper applications, or not maintaining file associations that you have set. As an example, if you set all text documents to open in Word instead of TextEdit, then while this setting should be preserved, sometimes it may revert after restarting or otherwise logging out and back into your account. A similar problem can happen in which you may see inconsistent applications placed in the Open With menu, showing up in some cases and not showing up in others.

File type associations in TextEdit's Info.plist file
The Info.plist file in each application contains document type definitions for the file formats that program is built to read. Screenshot by Topher Kessler/CNET

To tackle these problems should they arise, you can try various approaches to update the launch services on your system.

Open the application
If a program you have just added to the system is not showing up as an option for handling a file it should be able to open, try launching the program, followed by logging out and back in to your account to refresh the launch services. This should ensure that the program is included in the launch services. If the program still does not show up, then it might be that the developer did not include a definition for your specific file type in the program's info.plist file. However, you can overcome this by specifying the application to use. To do this, select the file to open and press Command-I to get information on it. Then choose Other from the Open With menu and after your desired application is selected, click the "Change All..." button.

Ensure applications are in the default locations
For various reasons the system may update its launch services databases, and when it does so it will look in default locations for application packages to read their info.plist files. For programs these locations are the Applications folder at the root of the boot drive, and the optional Applications folder in the user's home folder. As a result, if you place an application in an alternative location such as your desktop or on an external drive, then the system will not include it when updating the launch services (at least until you manually open it), so be sure you place your applications in one of these folders to ensure that it always shows up.

Manage corruption in the launch services
One of the primary reasons why the launch services will not include a program is if there is a corruption in them that prevents them from being updated or read by the user's account. In these situations, clearing and rebuilding the launch services database should restore proper functionality. To do this, open the Terminal utility and run the following command (copy and paste it, and provide your account password when prompted):

`sudo find /System/Library/Frameworks -name lsregister` -kill -seed

This command should locate the lsregister program and run it with the "-kill" and "-seed" flags that will delete it and repopulate it using the application packages in the default Applications folders.

If, after resetting the launch services, the system still does not retain file associations or show relevant applications in the Open With menu, then try fixing permissions and then manually purging the launch service databases. To do this, open Disk Utility and run a permissions fix on the boot drive. Then reboot to the OS X installer (the recovery partition in Lion, or an OS X install disk for Snow Leopard) and choose Reset Password from the Utilities menu (or choose the Terminal and run the command "resetpassword" in Lion), followed by selecting your account and choosing the option to reset permissions and ACLs on the specified home directory.

When this is done, reboot the system and then remove the launch services databases by the following procedure:

  1. Go to the Macintosh HD/Library/Caches folder and remove the file that begins with "com.apple.LaunchServices" in its name.
  2. Open the Terminal utility and run the following command:

    open $TMPDIR/..C/

  3. In the window that opens, locate and remove the file that also begins with "com.apple.LaunchServices" in its name.
  4. Follow these actions by running the following command to rebuild the launch services:

    `sudo find /System/Library/Frameworks -name lsregister` -kill -seed



Questions? Comments? Have a fix? Post them below or e-mail us!
Be sure to check us out on Twitter and the CNET Mac forums.