Calling libraries (maybe recursively)

I have made a main library (located in: Users/ldicroce/Library/Script Libraries/Lux MainLibrary.scptd) which contains several handlers I use very often.

Then I have an additional library (in the same folder) called Lux TestLibrary.scptd, with contains different set of handlers. Since some of them use handlers which are in Lux MainLibrary’s handlers, at the top of the script of the Lux TestLibrary.scptd I have:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use script "Lux MainLibrary"

So far so good…

Now I have an applet which use both libraries.
So at the top of the script I have included:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use script "Lux MainLibrary"
use script "Lux TestLibrary"

When I save this as Applet, I do not have any problem.
But if I then set in the “Bundle and Export Setting …” (of the File menu) the option “Include used user script libraries”, and then export this Applet as “Export Run-Only” → “Application (Apple”), SD crashes.

Even if both libraries are empty (only containing the “use script …” mentioned above), and the main script of the applet is just “beep” ( plus of course the “use script …” mentioned above), it still crashes …

Is this expected? Is there any way to overcome this?

Thanks Luciano

PS: I know that there is a topic “Embedding script libraries that call other libraries” written by Shane, but in my case I am not moving, editing, or deleting the library(s) from the original (and default) location, I am only trying to export the Applet as Run-Only with embedded libraries.

First, you shouldn’t be getting a crash. If you can send me the script and libs, I’ll take a look.

But the recursive problem is a it tricky. The problem is that if you move the app to a Mac without the libraries in a central libraries folder, Lux MainLibrary will no longer be in Lux TestLibrary's search path, and won’t be found.

Script Debugger attempts to work around this if possible, by adding symlinks between embedded libraries. But it doesn’t always work (and that sounds like where your crash is happening).

You’re safest option, if you can’t avoid the issue, is to add a copy of Lux MainLibrary to Lux TestLibrary.

Thanks. I won’t move any of these files. I just want to keep together the applet and the libraries which are compatible, since I often update them, and this might break the compatibility. see it more as a backup system.
Anyway it wast unclear to me what I was doing wrong and why SD was crashing, until you mentioned that I should not append.
I just send you all the files (by email), plus the crash log as BBEdit file.

Thanks.
Luciano

Thanks, I’ll check the files. I suspect this is the same bug someone else has already reported, and which is fixed in the next release.