Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Mac OS X 10.6

I created a very simple app, which is only a wrapper of a shell script (so that I can select this script in application selectors, like startup apps). I try to launch it and yesterday it worked, but today I changed the executable script's content and name (with something that perfeclty works in a shell script launched in the Terminal) and it will only display a Finder-iconed dialog saying

Cannot open the application because it is not supported on this kind of Mac.

I restored the previous script (content/name) but I still get the error! Same when re-bundling the app from scratch, or completely changing the bundle identifier…

If I try to open it in the Terminal using open, I get

The application cannot be opened because it has an incorrect executable format.

But when I executes directly the Contents/MacOS/Script, it allways works (iwth both contents). Also, it is displayed with correct icon and meta-information in the Finder (so I guess the Info.plist is understood).

The app's file tree is:

        Script    (executable bit set, works when launched directly)

Here is the Info.plist content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
    <string>My script</string>

And the PkgInfo file only contains APPL????. I tested the Script with a simple echo "ok" and echo "ok" >/tmp/test (plus #!/bin/sh header).

So my questions are:

  • Is there some kind of validity caching for applications ? based on what ? how do I flush it ?
  • Where does this message come from ? I tried to google it but all I get is a page talking about 32/64 bits Java…
share|improve this question

This is quite the necro, but I can't find another hit on google where this has been asked and answered. I finally figured it out (on 10.7 now):

The shell script file must begin with "#!" and here's the weird part: it must be at least 28 characters long.

If you put a 27 character script in, and touch the package, the icon will change to an app with a line through it. Add one character to the script and touch it again, and BOOM, it works.

Weird, no?

share|improve this answer
This is the most ridiculous thing I have ever heard, but it is completely true. 27 characters, it won't run. 28 characters, BAM! It works. – Schrockwell Feb 13 '14 at 7:10

You can create an application executing the script in Automator using a single Run Shell Script action.

share|improve this answer
yes I know, but I want to understand why this doesn't work – instanceof me Feb 28 '11 at 8:50
@streetpc I just created an application bundle from scratch. Worked on the first try. I did move it to another folder and back just before starting though to update launch services. My script file: #!/usr/bin/env bash | cd /Users/danielbeck | touch fooo with | being the line delimiter. chmod +x Script and that's it. fooo gets created on execute. – Daniel Beck Feb 28 '11 at 18:19

The shell script itself might be bad. This normally happens between PPC / Intel platforms or vice-versa.

share|improve this answer
As specified, the shell script executes correctly when launched directly the Terminal via – instanceof me May 27 '10 at 8:46
I meant the wrapper. Was it created with an older version / different architecture? – Josh K May 27 '10 at 12:28
the wrapper was created manually – instanceof me Feb 28 '11 at 8:49

You might want to check out Platypus:

"Platypus is a developer tool for the Mac OS X operating system. It can be used to create native, flawlessly integrated Mac OS X applications from interpreted scripts such as shell scripts or Perl, Ruby and Python programs. This is done by wrapping the script in an application bundle directory structure along with an executable binary that runs the script."

share|improve this answer
Thanks for your answer. I was wondering for the reason I was not unable to run my script (without notice) so using another tool isn't in the scope of this question, yet this tool seems nice. – instanceof me Dec 19 '11 at 15:49

I've successfully built applications whose executables are shell scripts. However, they have always gone on to exec a normal GUI process (or an atypical one such as a Java program); perhaps that makes a difference.

Also, have you controlled for the difference in environment variables? When you run from Terminal you get the dot files' effect (.profile, .bash_profile, .bashrc, etc.) but GUI launches don't use any of those. (That environment can be modified using ~/.MacOSX/environment.plist (relogin after changes), should you wish to do so.)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .