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.)
I have tried reinstalling the upgrade with no change of behaviour.. I'm now on 12.1, again with no change.