You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Edit: Please delete discussion. Resolved the issue by removing by adding @ to the start of the chunk name and removing the file extension.
I’m embedding Luau using mlua and I’m running into an issue with require() when loading scripts.
fn main() -> mlua::Result<()> {
let lua = mlua::Lua::new();
let path = std::path::Path::new("./lua/test.luau");
lua.load(path).exec()
}
./lua/test.luau
local test = require("./export")
test.hello()
./lua/export.luau
return {
hello = function()
print("Hello, world!")
end
}
This fails with the following error message:
runtime error: error requiring module "./export": could not reset to requiring context
stack traceback:
[C]: in function 'proxyrequire'
__mlua_require:13: in function 'require'
./lua/test.luau:1: in function <./lua/test.luau:1>
When I read the file to a String and load that the require works but subsequent requires do not work. I've tried changing the chunk name but that doesn't seem to help things.
I'm sure I'm missing something obvious but can't figure it out at the moment. If you could offer any guidance on how to use the crate properly that would be greatly appreciated.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Edit: Please delete discussion. Resolved the issue by removing by adding
@to the start of the chunk name and removing the file extension.I’m embedding Luau using mlua and I’m running into an issue with require() when loading scripts.
./lua/test.luau./lua/export.luauThis fails with the following error message:
When I read the file to a String and load that the require works but subsequent requires do not work. I've tried changing the chunk name but that doesn't seem to help things.
I'm sure I'm missing something obvious but can't figure it out at the moment. If you could offer any guidance on how to use the crate properly that would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions