Weird lua require behavior. Limit on how deep it goes for files?

Electra One mk2, recent firmware.

I’ve been trying to debug something and haven’t find a solution. All the code is plain lua, no electraOne functions or variables are there. I have my code living in the SD Card. All code works on another lua interpreter.

It seems like the require call has a limit on how deep it goes requiring stuff from libraries from a single call. Example: library1 requires library2. library2 requires library3 and 4, and so on.

More specific on the problem, I have a library pathPersistence that includes the following header.

local PersistenceClass = require('KdsLib.Kds.Persistence.PersistenceClass')
local kds = require('KdsLib.Kds.Kds')
local assignedProgram = require('KdsLib.Kds.Modules.AssignedProgram')

If I run the following:

local pathPersistence = require('KdsLib.Kds.Persistence.PathPersistence')
print('ready')

The Electra will just hang without an error displayed. However, if I require the header and then require the library, it works and i get the output ‘ready’.

local PersistenceClass = require('KdsLib.Kds.Persistence.PersistenceClass')
local kds = require('KdsLib.Kds.Kds')
local assignedProgram = require('KdsLib.Kds.Modules.AssignedProgram')
local pathPersistence = require('KdsLib.Kds.Persistence.PathPersistence')
print('ready')

There is no cyclic calling (again, this is tested in another lua interpreter), and if I try to trace to where it hangs, seems that it just stops “requiring” files and hangs after some deepness.

Is there a setting or memory allocated for the require statement? Everything indicates that I can require everything as long as I do it one by one, and do not let the module cascade the requirements. But that kinda seem weird!