How to install lua socket?


I’m experiencing this issue while trying to install a custom lua library, so I can use it in the scripts ;

orthanc | E0129 13:11:46.209987 OrthancException.h:85] Cannot execute a Lua command: error loading module ‘socket.core’ from file ‘/usr/lib/x86_64-linux-gnu/lua/5.1/socket/’:
orthanc | /usr/lib/x86_64-linux-gnu/lua/5.1/socket/ undefined symbol: luaL_openlib

When I print the _VERSION in the script, it says Lua 5.3 but when I check the libraries inside the docker, it’s only 5.1 - I don’t know if this is intended?

I’m using this docker script :

enable lua to find external modules (this list is obtained by running “return package.path” in a lua prompt)

ENV LUA_PATH=“./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua”
ENV LUA_CPATH=“./?.so;/usr/local/lib/lua/5.1/?.so;/usr/lib/x86_64-linux-gnu/?.so;/usr/lib/x86_64-linux-gnu/lua/5.1/?.so;/usr/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/”
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y liblua5.1-socket

And my LUA script:

require “socket”

I tried it from :!searchin/orthanc-users/docker$20lua$20socket|sort:date/orthanc-users/C9HfrMat3FQ/H9yeYlqxBwAJ

Ok so it looks like the base docker wheezy does only have LUA up to 5.2 so I can’t pull any 5.3 LUA scripts.

So I guess my question remains as ‘How do I install a custom lua package (like lua socket) with Orthanc docker?’

You could for instance:

  • Replace the base Docker image from “debian:wheezy-slim” to “debian:stretch-slim”:
  • Derive from “jodogne/orthanc”, compile Lua 5.3.5 from source in it (or copy binaries), and adapt the environment variables from my previous answer
  • Compile Orthanc from source, with the “-DUSE_SYSTEM_LUA=ON” command-line option to CMake, so as to use the binaries that are provided by your GNU/Linux distribution

Are these consecutive steps or I can do any of them to make it work?

This is a disjunction of possibilities, you can pick the one that best suits your needs.

Thanks for the directions.

I made it work with the debian:stretch-slim, I was able to install custom lua packages and use them.

But I ended up reverting everything, since the multipart packages that I was using didn’t work properly for me, and just used os.execute(curl command) for doing the multipart/form-data.

Thanks again