LUA no field package.preload

Hi folks,

Pretty new to HaProxy. Installed with LUA and able to trigger lua functoins. But have an issue is loading LUA modules. Say i want to use sha1.lua, not able to load the module inspite of file available in the said location. Getting this error:

Apr 13 16:00:52 a3 haproxy: no field package.preload[‘sha1’]
Apr 13 16:00:52 a3 haproxy: no file ‘/usr/local/share/lua/5.3/sha1.lua’
Apr 13 16:00:52 a3 haproxy: no file ‘/usr/local/share/lua/5.3/sha1/init.lua’
Apr 13 16:00:52 a3 haproxy: no file ‘/usr/local/lib/lua/5.3/sha1.lua’
Apr 13 16:00:52 a3 haproxy: no file ‘/usr/local/lib/lua/5.3/sha1/init.lua’
Apr 13 16:00:52 a3 haproxy: no file ‘./sha1.lua’
Apr 13 16:00:52 a3 haproxy: no file ‘./sha1/init.lua’
Apr 13 16:00:52 a3 haproxy: no file ‘/usr/local/lib/lua/5.3/sha1.so’
Apr 13 16:00:52 a3 haproxy: no file ‘/usr/local/lib/lua/5.3/loadall.so’
Apr 13 16:00:52 a3 haproxy: no file ‘./sha1.so’ from [C] global ‘require’, /home/xxxxxx/haproxy-plugin/dddd.lua:105 C function line 104.

I am using lua 5.3, haproxy 2.0.13 versions. To confirm its not a lua problem.

wrote a simple test.lua below:

local sha = require(“sha1”);
print(sha.sha1(“hello”));

on running this, command line , its perfect
[root@a3 haproxy-2.0.13]# lua test.lua
aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
[root@a3 haproxy-2.0.13]#

any ideas on what i am missing? your help is really appreciated.

Thanks,
Manic

Hi,

already a little bit aged, but stumbled into the same problem. Maybe this is usefull if someone else also ends up here:

Review the “lua-prepend-path” directive in haproxy documentation.
As the scripts are loaded with full path in the “lua-load”, this works fine for the script itself. But once you have a “require” statement in your script, it seems to default to look in $PWD and some other default dirs, instead of trying the scripts path location.

So long!