pandoc / dockerfiles

Dockerfiles for various pandoc images
GNU General Public License v2.0
364 stars 98 forks source link

[lua] module 're' not found #168

Closed gabyx closed 4 months ago

gabyx commented 2 years ago

Inside pandoc/latex:2.17-alpine I use https://github.com/pandoc/lua-filters/blob/master/include-files/include-files.lua

this gives the following error:

[INFO] Running filter /home/techmd/technical-markdown/tools/convert/filters/pandoc-include-files.lua
Error running filter /home/techmd/technical-markdown/tools/convert/filters/pandoc-include-files.lua:
module 're' not found:
        re is not one of pandoc's default packages
        no field package.preload['re']
        no file '/home/techmd/technical-markdown/tools/convert/filters/re'
        no file '/home/techmd/technical-markdown/tools/convert/filters/re.lua'
        no file ':/home/techmd/technical-markdown/tools/convert/filters/re'
        no file '/home/techmd/technical-markdown/tools/convert/filters/re.lua'
        no file '/usr/local/lib/lua/5.3/re.so'
        no file '/usr/local/lib/lua/5.3/loadall.so'
        no file '/usr/lib/lua/5.3/re.so'
        no file '/usr/lib/lua/5.3/loadall.so'
        no file './re.so'
        lpeg was configured to be excluded from the binary.
--------------------------------------------------------------

Is that a packaging error? Or is there a workaround? Is there a pandoc data-dir inside the image which is not searched above?

tarleb commented 2 years ago

Can you say a bit more about how you are using the image? Judging from the error message, there are some significant changes in the derived image. My guess is that the LUA_PATH variable has been changed.

gabyx commented 2 years ago

Ah ok, that is probably my error probably, despite that I actually add my paths

https://github.com/gabyx/TechnicalMarkdown/blob/feature/docker-image/build.gradle.kts#L207

gabyx commented 2 years ago

So far in my image: echo $LUA_PATH is empty. Actually this gradle setup works on native linux and macOS. Should the LUA_PATH variables point somewhere?

tarleb commented 2 years ago

I'd recommend against changing LUA_PATH in the image, as that will overwrite the default load path. If you do set it, then it's best to include the default package.path setting as well.

 % docker run --rm --entrypoint /usr/bin/lua5.3 pandoc/latex:2.17-alpine -e 'print(package.path)'
/usr/local/share/lua/5.3/?.lua;/usr/local/share/lua/5.3/?/init.lua;/usr/local/lib/lua/5.3/?.lua;/usr/local/lib/lua/5.3/?/init.lua;/usr/share/lua/5.3/?.lua;/usr/share/lua/5.3/?/init.lua;/usr/lib/lua/5.3/?.lua;/usr/lib/lua/5.3/?/init.lua;/usr/share/lua/common/?.lua;/usr/share/lua/common/?/init.lua;./?.lua;./?/init.lua

Or you could place an init.lua in your data-dir and update package.path in there.

gabyx commented 2 years ago

Ah thanks alot. I try this. I only need to add a few extra paths. Is there another better way, so init.lua will be read when pandoc starts its lua stuff, right?

tarleb commented 2 years ago

Right, init.lua is run each time pandoc starts up a new instance of the Lua interpreter (generally once for each filter file).

gabyx commented 2 years ago

@tarleb Do you know how to add paths in <current-init.lua-dir>/init.lua relative to the data-dir ?

package.path = package.path .. ";<current-init.lua-dir>/filters"

?

tarleb commented 2 years ago

Not sure. PANDOC_STATE.user_data_dir maybe?

tarleb commented 4 months ago

Please reopen if the issue persists.