I have installed cjson using Lua Rocks locally.
luarocks install --local lua-cjson
But I cannot access the module.
> require('cjson')
stdin:1: module 'cjson' not found:
Packages were installed in to ~/.luarocks. Following is the file structure
.
├── bin
│ ├── json2lua
│ └── lua2json
├── lib
│ ├── lua
│ │ └── 5.4
│ │ └── cjson.so
│ └── luarocks
│ └── rocks-5.4
│ ├── lua-cjson
│ │ └── 2.1.0.6-1
│ │ ├── bin
│ │ │ ├── json2lua
│ │ │ └── lua2json
│ │ ├── lua-cjson-2.1.0.6-1.rockspec
│ │ ├── rock_manifest
│ │ └── tests
│ │ ├── agentzh.t
│ │ ├── bench.lua
│ │ ├── example1.json
│ │ ├── example2.json
│ │ ├── example3.json
│ │ ├── example4.json
│ │ ├── example5.json
│ │ ├── genutf8.pl
│ │ ├── numbers.json
│ │ ├── octets-escaped.dat
│ │ ├── README
│ │ ├── rfc-example1.json
│ │ ├── rfc-example2.json
│ │ ├── test.lua
│ │ ├── TestLua.pm
│ │ └── types.json
│ └── manifest
└── share
└── lua
└── 5.4
├── cjson
│ └── util.lua
├── json2lua.lua
└── lua2json.lua
What are the environment variables that should be in place for Lua to be able to find the packages?
luarocks path prints everything that should be added
➜ ~ luarocks path
export LUA_PATH='/usr/share/lua/5.4/?.lua;/usr/share/lua/5.4/?/init.lua;/usr/lib/lua/5.4/?.lua;/usr/lib/lua/5.4/?/init.lua;./?.lua;./?/init.lua;/home/s1n7ax/.luarocks/share/lua/5.4/?.lua;/home/s1n7ax/.luarocks/share/lua/5.4/?/init.lua'
export LUA_CPATH='/usr/lib/lua/5.4/?.so;/usr/lib/lua/5.4/loadall.so;./?.so;/home/s1n7ax/.luarocks/lib/lua/5.4/?.so'
export PATH='/home/s1n7ax/.luarocks/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/s1n7ax/.s1n7ax/bin:/home/s1n7ax/.yarn/bin:/home/s1n7ax/.local/bin'
It just prints them NOT run them. So that needs to be ran. I added following line to init script to add the path at system boot
eval $(luarocks path)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With