Tuesday, September 27, 2022

#1 2015-11-07 07:40:56 am

druido
Member
Registered: 2010-09-03
Posts: 102

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:

Applescript:


on f()
return 42
end

and then another Foo.scpt script to invoke it:

Applescript:


set Bar to script "Bar"
Bar's f()

I would expect that running this from the command line would work:

OSA_LIBRARY_PATH="/path/to/my/foo/and/bar/scripts" osascript Foo.scpt


but I get

Foo.scpt: execution error: Can’t get script "Bar". (-1728)


What's wrong?


Filed under: OSA_LIBRARY_PATH

Offline

 

#2 2015-11-07 02:45:56 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6793

Re: Osa_library_path

I suspect more like:

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


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#3 2015-11-07 04:26:12 pm

druido
Member
Registered: 2010-09-03
Posts: 102

Re: Osa_library_path

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

Offline

 

#4 2015-11-07 06:20:23 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6793

Re: Osa_library_path

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:

Applescript:

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.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#5 2015-11-08 02:15:31 am

druido
Member
Registered: 2010-09-03
Posts: 102

Re: Osa_library_path

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

Offline

 

#6 2015-11-08 02:48:24 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6793

Re: Osa_library_path

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


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#7 2015-11-08 06:22:42 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2809
Website

Re: Osa_library_path

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.

Offline

 

#8 2015-11-08 11:16:40 am

druido
Member
Registered: 2010-09-03
Posts: 102

Re: Osa_library_path

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

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)