You are not logged in.

#1 2014-10-20 06:15:00

bdjnk
Member
Registered: 2009-08-24
Posts: 78

Wrong Lua path for openresty (Lapis).

For background, and to run though this yourself, see Getting Started With Lapis.

Running 'lapis server' and opening http://localhost:8080/ results in:

2014/10/20 01:47:01 [error] 29305#0: *1 lua entry thread aborted: runtime error: /home/bdjnk/Projects/LoE/web.lua:1: module 'lapis' not found:
	no field package.preload['lapis']
	no file '/usr/local/openresty/lualib/lapis.lua'
	no file '/usr/local/openresty/lualib/lapis/init.lua'
	no file './lapis.lua'
	no file '/usr/local/openresty/luajit/share/luajit-2.1.0-alpha/lapis.lua'
	no file '/usr/local/share/lua/5.1/lapis.lua'
	no file '/usr/local/share/lua/5.1/lapis/init.lua'
	no file '/usr/local/openresty/luajit/share/lua/5.1/lapis.lua'
	no file '/usr/local/openresty/luajit/share/lua/5.1/lapis/init.lua'
	no file '/usr/local/openresty/lualib/lapis.so'
	no file './lapis.so'
	no file '/usr/local/lib/lua/5.1/lapis.so'
	no file '/usr/local/openresty/luajit/lib/lua/5.1/lapis.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'

I took a look around and found that /usr/local/openresty/luajit/include/luajit-2.1/luaconf.h says this:

** Note to distribution maintainers: do NOT patch the following lines!
** Please read ../doc/install.html#distro and pass PREFIX=/usr instead.

#define LUA_LROOT       "/usr/local"

The issue can be fixed by adding package.path and package.cpath to nginx.conf, like so:

http {
	lua_package_path './?.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua;/usr/lib/lua/5.1/?.lua;/usr/lib/lua/5.1/?/init.lua';
	lua_package_cpath './?.so;/usr/lib/lua/5.1/?.so;/usr/lib/lua/5.1/loadall.so';

And that's as far as I've gotten in an hour of bumbling about.

This seems like it could be an openresty package problem, but I'm not sure where exactly the fault lies, let alone where a fix might fit.

Last edited by bdjnk (2014-10-20 06:16:56)

Offline

#2 2014-10-21 18:00:16

bdjnk
Member
Registered: 2009-08-24
Posts: 78

Re: Wrong Lua path for openresty (Lapis).

Manually setting lua_package_path and lua_package_cpath for nginx had unexpected negative consequences. My current work around is simpler.

# ln -s /usr/share/lua /usr/local/share/lua
# ln -s /usr/lib/lua /usr/local/lib/lua

Maybe I should try this on openresty pre install

$ sed -i -e 's/\/local//g' PKGBUILD

I'll do it when I have some time to mess with it.

Offline

#3 2014-11-24 07:04:18

eimis
Member
Registered: 2014-11-24
Posts: 5
Website

Re: Wrong Lua path for openresty (Lapis).

This solved the issue. Thanks for that!

Have you tried fixing the pkgbuild?

Offline

#4 2014-12-07 12:20:44

shanth
Member
Registered: 2013-02-04
Posts: 2

Re: Wrong Lua path for openresty (Lapis).

I had a similar issue. It was lua5.1 vs lua5.2. I then installed luarocks-5.1 from AUR, and installed lapis via luarocks-5.1.
That fixed it smile

Offline

Board footer

Powered by FluxBB