Problems importing external Lua library

I’m trying to use Luerl to import an external Lua library that claims to be compatible with Lua 5.1-5.4 with no other external dependencies, djot.

There isn’t much documentation on how to load external modules, so I played around a bit.

Given the following test.lua file:

local djot = require("djot")
local input = "This is *djot*"
local doc = djot.parse(input)
local html = djot.render_html(doc)


I checked out djot inside /tmp/playground so the Git repo ends up in /tmp/playground/djot. I then tried luerl:evalfile with a custom path, which seems to load all modules, but later gets a weird error:

1> os:putenv("LUA_PATH", "/tmp/playground/?/?.lua;/tmp/playground/djot/?.lua").
2>  luerl:evalfile("test.lua", luerl:init()).
          <<"s">>,<<"This is ">>,
          {luerl, ...

Is this a bug? Am I using the wrong API?

Not sure how to proceed here. I couldn’t find much documentation on how to load external Lua libraries with luerl…

(cc @DianaOlympos :wink:)


@rvirding Could surely help :slight_smile:

1 Like

Hmm. Could you test test.lua stepwise to see how far down you get. Luerl is generally compatible but some things do pop up which it can’t handle. I have4 never tried djot and I haven’t heard of anyone who has.

Try joining the luerl slack and asking there.


It fails first with the following lines:

local djot = require("djot")
local input = "This is *djot*"

Here’s the stack trace (without the luerl state, let me know if you want it).

1> luerl:evalfile("test.lua", luerl:init()).
    [{luerl_heap,raw_set_table_key, [{tref,81}, <<"s">>,<<"This is ">>, {luerl, ...}],
         [{file, "/tmp/playground/_build/default/lib/luerl/src/luerl_heap.erl"},
         [{file, "/tmp/playground/_build/default/lib/luerl/src/luerl_lib_basic.erl"},
         [{file, "/tmp/playground/_build/default/lib/luerl/src/luerl_emul.erl"},
         [{file, "/tmp/playground/_build/default/lib/luerl/src/luerl_emul.erl"},
         [{file, "/tmp/playground/_build/default/lib/luerl/src/luerl.erl"},

The invite link is broken. :frowning:

1 Like

Strange, the invite link marked here seems to work for me.

Which branch of Luerl are you using, the one you should use is develop. That is the one I will be working on.

1 Like

For some reason I got redirected to the old Heroku app somewhere. The GitHub link worked fine, thanks.

It’s develop but the error exists in 1.0 from Hex as well.

1 Like

I have found the bug and will push a commit tomorrow. You were the first person to run code which uses the rawset basic library function


Lovely! I’ll be gone for the holidays so expect a slow response. Happy holidays! :confetti_ball:

1 Like

Ah, is that a semicolon in the path?
Shouldn’t it be a colon?

1 Like

I have no clue! :sweat_smile: I scavenged my snippets together from various issues in the repo. There was no tutorial dealing directly with load paths and external libraries.

1 Like

So bug is (hopefully) fixed and commit pushed to develop.

@nzok I am totally missing something here. Which semicolon in which path?

1 Like