AppleScript does not function correctly after upgrade to MacOS 12

After upgrading to MacOS 12, Applescript seems to require elevated privileges to execute:

 osascript -e 'tell app "Finder" to display dialog "Hello, World!"'

results in:

osascript: can't open default scripting component.

whereas:

sudo osascript -e 'tell app "Finder" to display dialog "Hello, World!"'

outputs:

button returned:OK

Also:

osalang -L
ascr appl cgxervdh   ()
jscr appl cgxe-v-h  JavaScript (JavaScript)
scpt appl cgxervdh  JavaScript (JavaScript)

Whereas:

sudo osalang -L
ascr appl cgxervdh  AppleScript (AppleScript.)
jscr appl cgxe-v-h  JavaScript (JavaScript)
scpt appl cgxervdh  Generic Scripting System (Transparently supports all installed OSA scripting systems.)

Googling this problem returned limited suggestions. The most common seems to be a reinstall of the OS update. I’ll resort to this if I cannot find any alternatives.

Any help would be greatly appreciated!

Update: Reinstalling by downloading the update again has not remedied the issue.

There is a “with administrator privileges” phrase in AppleScript. Would that solve your issue?

Over here, in Monterey, the first time I attempt this osascript command I see

Once “OK” is clicked, the scriptlet works.

And, in System Preferences > Security & Privacy > Automation I see

image

These so-and-so wants access to control blah-blah are easy to miss in macOS.

Thanks for the reply @jec0047! :slight_smile: This is changed behavior from before the upgrade, so, I’m not keen to change anything at this stage. A lot of Alfred’s system functionality is not working now thanks to this problem for example.

@anon41602260 Thanks for your reply. I’m seeing:
Screen Shot 2021-11-24 at 3.42.24 pm
and:
Screen Shot 2021-11-24 at 3.42.18 pm
and:
Screen Shot 2021-11-24 at 3.42.44 pm

Just a note - this question might be good over on the Automators.fm forum as well. :slight_smile:

Thanks @webwalrus, that is a good idea.

Using fs_usage I managed to trace the problem to a 3rd party app creating problems. Once it’s uninstalled, osascript behaves as expected. More details can be found here: osacompile: no such component "App… | Apple Developer Forums

1 Like