1

I installed json-lua with luarocks install --local json-lua. Now when I run eval $(luarocks path) and require it from within the interpeter it can't find it. Here's my workflow:

(base) user@USR-0318:~/.luarocks/lib
 $ luarocks list

Rocks installed for Lua 5.1
---------------------------

busted
   2.2.0-1 (installed) - /home/user/.luarocks/lib/luarocks/rocks-5.1
   2.2.0-1 (installed) - /usr/local/lib/luarocks/rocks-5.1

dkjson
   2.8-1 (installed) - /home/user/.luarocks/lib/luarocks/rocks-5.1
   2.8-1 (installed) - /usr/local/lib/luarocks/rocks-5.1

json-lua
   0.1-4 (installed) - /home/user/.luarocks/lib/luarocks/rocks-5.1

lua-term
   0.8-1 (installed) - /home/user/.luarocks/lib/luarocks/rocks-5.1
   0.8-1 (installed) - /usr/local/lib/luarocks/rocks-5.1

lua_cliargs
   3.0-2 (installed) - /home/user/.luarocks/lib/luarocks/rocks-5.1
   3.0-2 (installed) - /usr/local/lib/luarocks/rocks-5.1

luafilesystem
   1.8.0-1 (installed) - /home/user/.luarocks/lib/luarocks/rocks-5.1
   1.8.0-1 (installed) - /usr/local/lib/luarocks/rocks-5.1

luassert
   1.9.0-1 (installed) - /home/user/.luarocks/lib/luarocks/rocks-5.1
   1.9.0-1 (installed) - /usr/local/lib/luarocks/rocks-5.1

luasystem
   0.5.1-1 (installed) - /home/user/.luarocks/lib/luarocks/rocks-5.1
   0.5.1-1 (installed) - /usr/local/lib/luarocks/rocks-5.1

mediator_lua
   1.1.2-0 (installed) - /home/user/.luarocks/lib/luarocks/rocks-5.1
   1.1.2-0 (installed) - /usr/local/lib/luarocks/rocks-5.1

penlight
   1.14.0-2 (installed) - /home/user/.luarocks/lib/luarocks/rocks-5.1
   1.14.0-2 (installed) - /usr/local/lib/luarocks/rocks-5.1

say
   1.4.1-3 (installed) - /home/user/.luarocks/lib/luarocks/rocks-5.1
   1.4.1-3 (installed) - /usr/local/lib/luarocks/rocks-5.1

(base) user@USR-0318:~/.luarocks/lib
 $ eval $(luarocks path)
(base) user@USR-0318:~/.luarocks/lib
 $ echo $LUA_PATH
/usr/local/share/lua/5.1/?.lua;./?.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;/home/user/.luarocks/share/lua/5.1/?.lua;/home/user/.luarocks/share/lua/5.1/?/init.lua
(base) user@USR-0318:~/.luarocks/lib
 $ lua
Lua 5.3.6  Copyright (C) 1994-2020 Lua.org, PUC-Rio
> require("json")
stdin:1: module 'json' not found:
        no field package.preload['json']
        no file '/usr/local/share/lua/5.1/json.lua'
        no file './json.lua'
        no file '/usr/local/share/lua/5.1/json/init.lua'
        no file '/usr/local/lib/lua/5.1/json.lua'
        no file '/usr/local/lib/lua/5.1/json/init.lua'
        no file '/usr/share/lua/5.1/json.lua'
        no file '/usr/share/lua/5.1/json/init.lua'
        no file '/home/user/.luarocks/share/lua/5.1/json.lua'
        no file '/home/user/.luarocks/share/lua/5.1/json/init.lua'
        no file './json.so'
        no file '/usr/local/lib/lua/5.1/json.so'
        no file '/usr/lib/x86_64-linux-gnu/lua/5.1/json.so'
        no file '/usr/lib/lua/5.1/json.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file '/home/user/.luarocks/lib/lua/5.1/json.so'
stack traceback:
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: in ?
>

I saw that the json library is installed in the .luarocks/lib directory but this is not put on LUA_PATH when executing luarocks path. I feel like im doing something wrong since all the sources say it should work just like that? What am I missing?

1 Answer 1

1

If found out that I needed to require("JSON") instead of require("json") The later would be the suitable import for the C-implementation lua-json. But I wanted the pure lua lua-json.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.