lapis icon indicating copy to clipboard operation
lapis copied to clipboard

Problems with cjson.so: undefined symbol: lua_objlen

Open rafauke opened this issue 3 years ago • 1 comments

Hello,

I am following the tutorial and I have installed lapis with luarocks, but it looks like cjson is not working correctly. It shows warnings during lapis installation and then throws when trying to use lapis command.

Installation:

lua-cjson 2.1.0.6-1 depends on lua >= 5.1 (5.4-1 provided by VM)
gcc -O2 -fPIC -I/usr/include -c lua_cjson.c -o lua_cjson.o
lua_cjson.c: In function ‘json_append_data’:
lua_cjson.c:743:19: warning: implicit declaration of function ‘lua_objlen’; did you mean ‘lua_len’? [-Wimplicit-function-declaration]
  743 |             len = lua_objlen(l, -1);
      |                   ^~~~~~~~~~
      |                   lua_len

and when running lapis:

/usr/bin/lua5.4: /usr/share/lua/5.4/luarocks/loader.lua:104: error loading module 'cjson' from file '/home/user/.luarocks/lib/lua/5.4/cjson.so':
        /home/user/.luarocks/lib/lua/5.4/cjson.so: undefined symbol: lua_objlen
stack traceback:
        [C]: in local 'a_loader'
        /usr/share/lua/5.4/luarocks/loader.lua:104: in function </usr/share/lua/5.4/luarocks/loader.lua:101>
        (...tail calls...)
        [C]: in function 'require'
        /home/user/.luarocks/share/lua/5.4/lapis/util.lua:2: in main chunk
        [C]: in function 'require'
        .../user/.luarocks/share/lua/5.4/lapis/cmd/util.lua:7: in main chunk
        [C]: in function 'require'
        ...user/.luarocks/share/lua/5.4/lapis/cmd/actions.lua:3: in main chunk
        [C]: in function 'require'
        ....luarocks/lib/luarocks/rocks-5.4/lapis/1.9.0-1/bin/lapis:3: in main chunk
        [C]: in ?

It looks like this workaround fixes the problem: https://github.com/mpx/lua-cjson/issues/56#issuecomment-394764240

$ luarocks remove lua-cjson
$ luarocks install lua-cjson 2.1.0-1

I'm just leaving it here, because maybe someone else will have the same similar issue. Cheers :)

rafauke avatar May 02 '21 19:05 rafauke

Didn't work for me.

EDIT:

Actually this one worked out.

$ luarocks remove lua-cjson
$ luarocks install lua-cjson 2.1.0-1

But it's old package. So issue is still there if updated.

filu34 avatar May 20 '22 22:05 filu34

Closing this as the version of cjson in LuaRocks will work with all versions of Lua

leafo avatar Nov 07 '22 21:11 leafo