23

I have an application that I have been developing for some time now. Recently launching the application via a double click presents a dialog that says "You can't open the application RepoWatch because it may be damaged or incomplete."

Launching the application via open ./RepoWatch.app gives me "The application cannot be opened because its executable is missing."

I usually launch the application via ./RepoWatch.app/Contents/MacOS/RepoWatch simply out of habit (which DOES work), so I am unsure how long this has been happening, or what change happened immediately before hand. The most likely change is that I put cp Info.plist ./RepoWatch.app/Contents/ into my make file in order to version Info.plist without versioning everything in the .app bundle.

I have looked at Info.plist many times and cannot find anything wrong with it. The file opens up with Property List Editor without any errors. Saving from Property List Editor does not make the file "work" (if it is to blame in the first place).

The permissions as far as I can tell also look sane:

$ ls -l
./RepoWatch.app/Contents/Info.plist
-rw-rw-r--@ 1 dgrace  staff  789 Feb  1 23:20 ./RepoWatch.app/Contents/Info.plist
$ ls -l
/Applications/Adium.app/Contents/Info.plist
-rw-rw-r--  1 dgrace  staff 5750 Aug 21 15:41 /Applications/Adium.app/Contents/Info.plist

I am at a loss as to what to try next.

And here are the contents of Info.plist (Even though nothing has really changed in quite a while):

<?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>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleExecutable</key>
    <string>RepoWatch</string>
    <key>CFBundleIdentifier</key>
    <string>com.doomstick.RepoWatch</string>
    <key>CFBundleName</key>
    <string>RepoWatch</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0.0</string>
    <key>LSMinimumSystemVersion</key>
    <string>10.6</string>
    <key>CFBundleVersion</key>
    <string>Beta26</string>
    <key>NSMainNibFile</key>
    <string>MainMenu</string>
    <key>NSPrincipalClass</key>
    <string>NSApplication</string>
</dict>
</plist>
Daniel Grace
  • 378
  • 1
  • 2
  • 11
  • Did you forget to include the output of `ls -l /Applications/Adium.app/Contents/Info.plist`, or did you not mean to include that command in the first place? – Peter Hosey Feb 02 '10 at 05:44
  • I was having problem with the formatting of that block and it got deleted somehow. It's been added in. I've also removed the extended attributes of my file and that made no difference. – Daniel Grace Feb 02 '10 at 06:56
  • “… I am unsure how long this has been happening, or what change happened immediately before hand.” If your version-control system has a bisect command, now would be the time to use it. (If you're not using version control, this is a fine demonstration of one reason to do so.) – Peter Hosey Feb 02 '10 at 07:15
  • I do not have the .app or anything underneath it under version control. That's the reason why I moved Info.plist out, so it could effectively be under version control. Bisect did not help. All of them were 'bad' as it's something outside of version control, it seems. The simple solution is probably to trash the .app and recreate it. But I'm very curious as to what the underlying problem is. – Daniel Grace Feb 02 '10 at 09:58
  • I'm having this same problem. The `.app` works, but when I copy it (from this question it looks like something changes with `Info.plist`) using Ant it stops launching, but if I copy it manually it still works. – Raekye Aug 01 '13 at 20:17

5 Answers5

22

Building on the answer that @smokris posted:

The problem seems to be with your app's registration in the Launch Services database. There is no need to rebuild the entire database. To force-update the entry for your app (specifically), use lsregister with the -f option:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f MyApp.app

I was having the same problem you describe, and this worked for me. Thanks, @smokris!

Stuart Berg
  • 17,026
  • 12
  • 67
  • 99
13

Rebuilding the Launch Services database solves this problem for me.

Try executing the following command in Terminal:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
smokris
  • 11,740
  • 2
  • 39
  • 59
  • 1
    A side effect of rebuilding the Launch Services database is that it forgets all of the times you said "yes" to "X is an application downloaded from the internet. Are you sure you want to open it?". To test if `lsregister` is likely to fix the problem: Make a copy of the .app. Can you run the copy? If so, run `lsregister`. – jlstrecker Jan 30 '13 at 03:18
  • 3
    To update the Launch Services database for your app without rebuilding the whole database, use the `-f` option: http://stackoverflow.com/a/16546673/162094 – Stuart Berg Jul 06 '13 at 15:06
6

The problem is likely due to an invalid CFBundleExecutable property value in the Info.plist file you are copying into the application.

In Xcode projects the default value for this property is a special variable (placeholder) value (${EXECUTABLE_NAME}) that is expanded (replaced) when the build system builds the application. Are you sure you need to copy this file manually? Maybe you can add a script build phase that makes whatever changes you need after it has been expanded and copied into place by the normal build process.

While you are at it, you should check for other placeholder values in the file. It is likely that you will need to fill in CFBundleName (others may also be necessary, depending on your application type).

Chris Johnsen
  • 214,407
  • 26
  • 209
  • 186
  • I'm not using XCode. I know, I'm a heretic. The CFBundleExecutable hasn't changed since I started copying the file over. That's the most logical answer, but I can't find any thing that has made that value now invalid. – Daniel Grace Feb 02 '10 at 06:15
  • I brought this answer back, even though it was useless. I failed to consider whether the comment would still be useful before I deleted the answer. – Chris Johnsen Feb 06 '10 at 07:55
  • 1
    This happened to me on a case sensitive filesystem, where the CFBundleExecutable property used the right executable name, but uppercased and the executable was lowercase. Funnily, the `.app` worked inside its `.dmg` but not on my `/Applications` folder, which suggests that this particular `dmg` was case insensitive. – Paul Mougel Aug 28 '14 at 14:31
2

OK, some (more) shots in the dark.

  1. The docs for LSMinimumSystemVersion say that the value is supposed to be a string with the form n.n.n. You might try adding a “.0” to the end of your value.
  2. When you use ./RepoWatch.app/Contents/MacOS/RepoWatch to run it manually, are you using some sort of completion or filename generation, or are you typing it all in (especially the filename of the executable)?
    • Maybe the executable filename has some odd invisible/combining/look-alike character in it that does not match the value in Info.plist. Try ls -w /path/to/RepoWatch.app/Contents/MacOS/ | xxd to look at the bytes for anything non-ASCII.
  3. Does plutil -lint /path/to/Info.plist give you an “OK”?
  4. The @ after the permissions in the ls -l output indicates some xattrs. These could be harmless, but have you looked at which ones are there with ls -l@?
    • If one of the xattrs looks suspect (or even if not) you could (cd /path/to/RepoWatch.app/Contents/ && mv Info.plist Info.plist.save && cat Info.plist.save > Info.plist) to get a copy without the xattrs and test with it.
    • If using the non-xattr'd file still causes problems, you might try systematically modifying and deleting keys (after making a backup copy, like the .save above) to see if you can cause a different error message that might help indicate the problem.
Chris Johnsen
  • 214,407
  • 26
  • 209
  • 186
  • I am about to step out and just now noticed the new answers. Is there a way to make SO send me an email on answers? I quit looking at this regularly after the first 24 hours or so. I removed the xattrs. That didn't help. I will try the rest when I return. I am especially interested in the plutil -lint. I did not know that command, and was assuming that the plist editor would tell me if anything was wrong. – Daniel Grace Feb 06 '10 at 05:38
  • Of your suggestions, the only thing that struck me as somewhat odd: $ ls -w ./RepoWatch.app/Contents/MacOS/ | xxd 0000000: 5265 706f 5761 7463 680a RepoWatch. 0a seems to be a line feed, and shows up as a period on the right hand side. Is this just because it's an odd number of characters, or is this actually a problem? – Daniel Grace Feb 06 '10 at 05:47
  • Notifications: When asking a question there is a “Notify _ daily of new answers” checkbox, is that option there once you have asked a question (maybe only in edit?)? Also on you profile page (click your name at the top of any) under “prefs”, is another notifications checkbox. See http://meta.stackexchange.com/questions/24659/instant-email-alerts-and-notifications and http://meta.stackoverflow.com/search?q=email+new+answers – Chris Johnsen Feb 06 '10 at 07:47
  • The `0a` is just the usual terminating linefeed from `ls`, nothing to worry about (the `-w` option just prevents `ls` from printing `?` instead of the raw byte if it thinks it is unprintable in the current environment). – Chris Johnsen Feb 06 '10 at 07:50
0

Project Menu > Set Active Executable