leafo / lapis

A web framework for Lua and OpenResty written in MoonScript
http://leafo.net/lapis/
MIT License
3.14k stars 247 forks source link

lpeg undefined symbol #740

Closed bodonkerhoderos closed 3 years ago

bodonkerhoderos commented 3 years ago

hey i'm having trouble getting lapis to run the default project .

i have installed openresty and luarocks from AUR and then followed the lapis getting started page but opening it in the browser yields:

2021/07/05 23:36:44 [error] 232618#0: *1 lua entry thread aborted: runtime error: error loading module 'lpeg' from file '/usr/lib/lua/5.4/lpeg.so':
    /usr/lib/lua/5.4/lpeg.so: undefined symbol: lua_getiuservalue
stack traceback:
coroutine 0:
    [C]: ?
    [C]: in function 'require'
    /usr/share/lua/5.4/lapis/router.lua:4: in main chunk
    [C]: in function 'require'
    /usr/share/lua/5.4/lapis/application.lua:4: in main chunk
    [C]: in function 'require'
    /usr/share/lua/5.4/lapis/init.lua:1: in main chunk
    [C]: in function 'require'
    content_by_lua(nginx.conf.compiled:22):2: in main chunk, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:8080"

(irrelevant but notable that i did have to roll back the lua-cjson version as described in #739)

i guess first question is is there something i'm doing wrong? the error leads me to think that (this version of) lpeg is incompatible with luajit. the rockspec file for lpeg indicates it is compatible with lua 5.1

currently i have lpeg version 1.0.2-1 installed. but i tried walking down the line and couldn't get other versions to work as they either threw the same error or other symbols were undefined.

leafo commented 3 years ago

This can happen if you've compiled and installed a native module using LuaRocks configured for a later version of Lua (5.4, 5.3, etc.) that you're trying to load into openresty with luajit which is compatible with Lua 5.1 shared libraries only.

Typically LuaRocks will have different install paths for each version of Lua. Ensure that you're installing Lapis with LuaRocks configured for 5.1, and then ensure that OpenResty isn't using incorrect LUA_PATH, LUA_CPATH environment variables for a different version of Lua.

You can use the following command to install for Lua 5.1:

luarocks --lua-vesrion=5.1 install lapis

Personally though, I install all my modules using --local like so: luarocks --local --lua-vesrion=5.1 install lapis

The following command will then show the appropriate environment variables to set the path for the specified version:

luarocks --lua-version=5.1 path

You can override the LUA_PATH and LUA_CPATH environment variables directly in your OpenResty config using the lua_package_path and lua_package_cpath directives: https://github.com/openresty/lua-nginx-module#lua_package_path

bodonkerhoderos commented 3 years ago

ah perfect thank you! i knew there was something basic i was missing :)

should i draft up a paragraph with this info for the docs in the getting started section?