OS X EL Capitan has introduced a new environment variable called OSA_LIBRARY_PATH, which may be used to specify additional location for script libraries. I cannot make it work, however. I have tried making a Bar.scptd script bundle containing a function:
on f()
return 42
end
and then another Foo.scpt script to invoke it:
set Bar to script "Bar"
Bar's f()
I would expect that running this from the command line would work:
Perhaps someone who knows more about shell scripting can help. I saved your first script as Bar.scpt on my desktop. I then set up an ASObjC project in Xcode, set it to run with the Environment Variable OSA_LIBRARY_PATH set to /Users/shane/Desktop, and then edited the app delegate as follows:
on applicationWillFinishLaunching_(aNotification)
set Bar to script "Bar"
set x to Bar's f()
display dialog (x as text)
end applicationWillFinishLaunching_
I suspect it’s actually meant to be used in Objective-C projects. The idea is that it lets an editor compile a script-and-library combination without having to save the library in a public folder (which has potential repercussions if something goes wrong). Think something like, oh, ASObjC Explorer
Use export which enables the variables into processes and sub processes while a normal variable only is available in it’s own environment. I’m using to run AppleScript-editor in the debugger for AppleScript Toolbox by using the variable DYLD_FRAMEWORK_PATH.