QuickTime component causing errors when running osascript command

If I run a simple osascript from the command line:

osascript -e 'tell app "Safari" to activate'

I get hundreds of this error:

I have to wait for the errors to finish running before the script actually runs, which is annoying.

I tried using codesign to fix the issue:

But it didn’t help. I believe the error is caused by Mojave’s security policy.

One way to fix this is to remove the the QuickTime component from this folder. But I’m hoping there is a better fix as the EyeTV app requires this component to run.

And why is this EyeTV executable even getting run? It has nothing to do with script. I’m very confused by this.

Thanks.

Where are you getting this error?

In the terminal.

Are you sure you don’t mean in Console.app, or do you have terminal logging on?

You can try checking that NSScriptingDebugLogLevel is set to 0. You might also want to check out the environmental variables here:

https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/LoggingDynamicLoaderEvents.html

I’m typing the command indicated above at the command prompt in iTerm2. This one:

osascript -e 'tell app "Safari" to activate'

Then hundreds of the same errors spew out for about 2 to 3 seconds.

Based on the error code I cited in the OP, this is an issue with AppleScript not loading a component supplied by EyeTV. So I don’t think debugging will be of any help. I need to find a way to fix the component or somehow prevent OSA from loading it (without resorting to moving the component out of the /Library/QuickTime directory entirely. I have no earthly idea how or why osascript is even trying to load that component or what it’s trying to do. Are these scripting additions? I just don’t know.

Did you try it?

No, and I see no provision in the man page for osascript for turning that switch on.

Can someone help me understand why the osascript command is even loading QuickTime components? What is going on under the hood?

osascript needs to load an AppleScript component via the component manager, which is presumably loading all components. NSScriptingDebugLogLevel controls whether such loading events are logged. Do a search on NSScriptingDebugLogLevel.

I did do a search. Only got like 10 results on it and nothing that clearly indicated how to use it/turn it on.

I’ve been doing some other reading and discovered the component manager was deprecated back in 10.8: https://developer.apple.com/documentation/coreservices/carbon_core/component_manager

That was quite a while ago. Is it still in use?

The books/blogs/resources on AppleScript/OSA seem very dated. There is a disclaimer across the top of AppleScript documentation site that the documentation isn’t kept up anymore:

But if I do a search on the site it refers me to gives links that refer me back to the documentation no longer being updated!

So, I’m pretty much at a loss as to where to go for authoritative and correct documentation.

Let’s assume Component Manager is still around. Is there a way to control what dynamic bundles it loads?

This is about the second I came up with:

https://cocoadev.github.io/DebuggingAppleScriptSupport/

You use defaults.

Try running your code in Terminal – iTerm2 might be trying to be helpful by setting other environmental variables, or having NSScriptingDebugLogLevel set to 1.

Yes.

Removing them, probably. But what’s being loaded (or not) is not your problem: what you want to stop is the excessive logging.

Thanks for the help. I used the commands there to turn off logging but to no avail.

I think I’m just going to write a bash script for those commands so they temporarily move the QT component out of the directory they are in and then move them back after the command executes.

Here’s what I came up with. It goes in the .bashrc file. Be sure to resource the .bashrc file or start a new terminal window so it will take effect.

function osascript() {
	if [ -e "/Library/QuickTime/EyeTV MPEG Support.component" ]; then
		mv "/Library/QuickTime/EyeTV MPEG Support.component" ~
	fi
	command osascript "$@"
	if [ -e "${HOME}/EyeTV MPEG Support.component" ]; then
		mv "${HOME}/EyeTV MPEG Support.component" "/Library/QuickTime/"
	fi
}

It’s a horrible hack, but the best solution I could come up with. I’m all ears if anyone has anything better.