Osa_library_path

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:

but I get

What’s wrong?

I suspect more like:

OSA_LIBRARY_PATH=“/path/to/my/bar/scripts/folder” osascript /path/to/Foo.scpt

No way. For me that variable has no effect whatsoever.

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 ran it and it worked fine.

Ah, you’re right. So, maybe it’s meant to be used in ASObjC projects only, and it is ignored by osascript.

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 :wink:

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.

Exporting the variable doesn’t change anything. I think that it is not meant for use in the command line.