Export Run-Only breaks applet - causes “Couldn't communicate with a helper application” error

I have an Automator Service which loads a script from inside my applet. That script does some work then loads another script and runs a handler inside that. The handler initiates a background osascript which runs another script. All the scripts are inside the applet’s bundle.

The Service can be invoked from a web browser or other app and it works. However, if the applet is exported Run-Only (using Script Debugger), the Service fails with an error:

Helper error - only if exported !!

I’ve found that the problem occurs at the point the handler tries to initiate the background osascript. There are no AppleScript errors. If I put a try/error block around the “do shell script osascript” call I get this error:

Error in [first script]: The command terminated due to receipt of a signal.

Does anyone know what exporting to Run-Only does to scripts inside a bundle which could prevent access from a Service ?

Thanks.

It smells like a permissions issue, but quite what or why, it’s hard to say – they’re sort of designed to be obtuse errors, to discourage workarounds. Can you make up a very minimal example?

Yes, that’s what I found back in March 2022 when I first saw the error. I gave the Applet and the Service full disk access and the error stopped. So, I released the applet to users. Now the same version of the Applet fails with this error even though the Applet, the Service and Safari (used to invoke the Service) have full disk access. The Applet and Safari also have Automation permissions and all three have Accessibility permission.

I’ve also checked the permissions on the various scripts. They are the same:

  • [User] has read/write
  • “Wheel” has read only
  • “Everyone” has read only

I can’t think of any other permissions that could be granted.

I’ve been trying to get the last script to send back a more useful error message. So far all I’ve got is:

The command terminated due to receipt of a signal.

UPDATE: Now have more detail:

sh: line 1: 747 Segmentation fault: 11

sh then echoes back the content of the call which I can check.

UPDATE: Have confirmed that the call to the last script contains the same data when invoked from the Service or directly from the Applet.

UPDATE 2: Probably should make the whole process simpler instead of the current convoluted steps.

Fredrik, thanks.

The binary inside Contents/macOS/ is the default universal “applet” binary provided by Script Debugger/Script Editor. Can you advise on how to execute that to get logging ?

I’ve checked various logs (e.g System log) but found no report that’s relevant.

Does anyone know why running an exported applet would cause segmentation error ?

UPDATE: I found another error which make no sense to me. The Service is an AppleScript and that script bangs this error:

“Finder got an error: Parameter error.”

The error is on this tell block:

tell application "Finder"
	set appPath to (application file id "com.apple.script.id.[mySpplet]" as string)
end tell

I’ve had that tell block in the Service for over 5 years so, why would it be a problem now ? In any case I tested that code in SD and had no errors.

UPDATE 2: I’ve tried two more ways of finding the path to an app:

tell application "Finder"
	set appPath to (url of (application file id "com.apple.script.id.[mySpplet]")) as string
end tell
tell application "Finder"
	set appPath to (container of (application file id "com.apple.script.id.[mySpplet]")) as string
end tell

Both fail with “Finder got an error: Parameter error.”.

UPDATE 3: Question answered – I misunderstood the Bundle ID settings in Script Debugger so instead of having the correct ID, I was exporting with the ID “com.yourcompany.[myApplet]”. So, Finder could not find it. Must have accidentally changed a setting in SD in recent times.

But that hasn’t solved the original question – what does exporting as a Run-Only Apple application do to cause such an error ? [“terminated due to receipt of a signal”]

I’ve given up trying to find the root of the permissions issue. I will implement a workaround in which (1) the apple is saved in SD, (2) two script files are removed from the bundle, (3) the bundle is exported Run-Only, (4) the two files are moved back into the bundle, and, (5) the applet is notarized.

I suspect that an external script (e.g. a Service) cannot load a Run-Only script that is inside an applet bundle which I guess makes some sense.

Cheers.