No Standard IO library in a SessionInit lua script

io lua library seems to be not loaded in a SessionInit script :

ardour {
	["type"]    = "SessionInit",
	name        = "Test Template",
	author      = "An author",
	description = "A description"

function factory () return function (...)
end end

with the following result :

2022-04-18T00:21:12 [INFO]: LuaTemplate: nil

On the other hand, it works very well in the scripting window in Ardour.

Does someone have an idea ?

Script interpreters are sandboxed (mainly for realtime safeness [1[). Only the GUI Window and Editor-Actions are whitelisted.

I cannot think of a reason why Session-init scripts cannot be whitelisted either, but so far it isn’t.

[1] by default neither the os and the io library are available, nor is dofile, loadfile, coroutiine, require. In general anything call that may perform file i/o or syscalls or include external files (which may not be present on other systems) is not allowed.

Thanks for your quick response.

It seems raisonable that the Session-Init scripts can use the os and io library because there is no real time constraint.

In my use case, I have to read some track informations from external files to setup my sessions.

I found the lua.sandbox (true) in the meta_session_setup function.

May I propose a Pull Request on GitHub with this change ?

Yes, that’s a great idea!

So my first Pull Request is to change a boolean :grinning:

I use Windows at home so I build a linux version of ardour with WSL to test the change.

It was an informative trip but I am interested in the Windows build procedure so that it is more representative of my use.

You have to start somewhere.

We cross compile Windows binaries on Linux using mingw.