Osascript: Bad CPU type

I used to run QuicKeys, which worked like a charm from 10.6 to 10.9. Now I recently updated to El Capitan, doing a new and clean setup of 10.11.6 on several machines (iMac, Mini & Book, all 2011). As QuicKeys does not run smooth in 10.11.6, I use now Keyboard Maestro v9, and its registered with System Preferences/Security & Privacy/Privacy/Accessability.
The problem: Applescripts with Keyboard Maestro do NEVER work (even the most simple ones like "set x to 1"...), whether they are called or executed with KM. The only result I get is "arch: posix_spawnp: /usr/bin/osascript: Bad CPU type in executable".
I have tried finding out with Google what that should be, but in vain.
Why should I have a bad CPU in osascript??

Some explanation about it? Without Applescript, KM is of no use to me...
Thanks very much for help.

This doesn't work on your system?


No, unfortunately not. BTW, this is also my test script :slight_smile:
Result is the error with the bad CPU type

OK, a few more questions:

  • Does it run successfully from the Script Editor?

  • Can you execute osascript -e 'tell app "System Events" to display dialog "Hello, world"' from Terminal?

That error relates to issues with 32-bit vs 64-bit architectures.

You shouldn't have an issue normally unless you have 32-bit osaxen installed.

Try in the Terminal these three commands:

/usr/bin/arch -i386 /usr/bin/osascript -e 'set x to 1'
/usr/bin/arch -x86_64 /usr/bin/osascript -e 'set x to 1'
defaults read com.stairways.keyboardmaestro.engine OSAScriptCommand

and show what results you get.

This are the results:

Last login: Thu Apr 23 08:02:15 on console
myMini:~ rod$ /usr/bin/arch -i386 /usr/bin/osascript -e 'set x to 1'
arch: posix_spawnp: /usr/bin/osascript: Bad CPU type in executable
myMini:~ rod$ /usr/bin/arch -x86_64 /usr/bin/osascript -e 'set x to 1'
myMini:~ rod$ defaults read com.stairways.keyboardmaestro.engine OSAScriptCommand
/usr/bin/arch -i386 /usr/bin/osascript
myMini:~ rod$

On High Sierra I get the same results as you on the first two commands, indicating the 64-bit architecture functions but the 32 doesn't.

(Reading the default, though, just returns the error, The domain/default pair of (com.stairways.keyboardmaestro.engine, OSAScriptCommand) does not exist.)

Here's some osaxen trouble shooting tips to chase down the culprit.

That is your problem.

You are actively setting Keyboard Maestro to use the 32 bit variant of osascript. You have, at some point in the past, actively configured this setting since there is no other way for it to be set.

Just remove this setting:

defaults delete com.stairways.keyboardmaestro.engine OSAScriptCommand

I'm not sure whether you have to restart the Keyboard Maestro Engine or not.

Sorry for responding late, but I was not connected to Internet for a few days.

I followed Ivan Königs tip (given via another by creating a new user, and then KM had no problem with Applescript. I then got back to my normal user, put ALL user preferences out of the preferences folder and set them aside (for eventual further use), and the error was gone. Wonderful.
I had put all third party preferences back into the preferences folder, and Keyboard Maestro still works fine with AppleScript. The conclusion: it must be one of Apples preference files who was the culprit. I had not yet time to figure out, which one it was, but I will do this sometime.

@peternlewis: I do not recall having ever set such a preferences since trying out KM, but I deleted (just for testing purposes) many times the file com.stairways.keyboardmaestro.engine, without having any remedy. But anyhow, now it rocks...

Thanks all for their valuable help.

The preference files are often cached by the system, so deleting them may not actually accomplish anything.

Use the defaults command to adjust the preferences.