Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LuaJIT not seeing rocks installed by LuaRocks

lua -e "print(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

luajit -e "print(package.path)"

./?.lua;/usr/local/share/luajit-2.0.0-beta8/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua

I've tried appending lua's package.path, no dice though. LuaJIT just can't seem to find any of the rocks, it's weird. What should I do here?

like image 280
Matthew Blanchard Avatar asked Jul 23 '11 22:07

Matthew Blanchard


3 Answers

If you've installed the module using luarocks, but not as root, stick: require 'luarocks.loader' before you include the module and it should be included without the error.

like image 105
U319344 Avatar answered Sep 21 '22 02:09

U319344


Two suggestions:

1. Install rocks as root to get them in /usr/local
2. Use ldconfig to update shared library cache

Example:

e@eSammy:~$ sudo luarocks install lsqlite3
[sudo] password for e:
Installing http://luarocks.org/repositories/rocks/lsqlite3-0.8-1.src.rock...
...
lsqlite3 0.8-1 is now built and installed in /usr/local/ (license: MIT/X11)
e@eSammy:~$ sudo /sbin/ldconfig
[sudo] password for e:
e@eSammy:~$ rlwrap luajit
LuaJIT 2.0.0-beta8 -- Copyright (C) 2005-2011 Mike Pall. http://luajit.org/
JIT: ON CMOV SSE2 SSE3 ATOM fold cse dce fwd dse narrow loop abc fuse
> require 'lsqlite3'
> =sqlite3.version()
3.7.7.1
> os.exit()
e@eSammy:~$ 
like image 22
Doug Currie Avatar answered Sep 22 '22 02:09

Doug Currie


On a Mac? Running brew?

Install lua51, which is packaged with luarocks aliased as luarocks-5.1:

brew install luajit lua51
eval `luarocks-5.1 path --bin` # exports LUA_PATH, LUA_CPATH, PATH
luarocks-5.1 install socket
luajit -e 'print(require("socket"))'
like image 22
Garth Kidd Avatar answered Sep 21 '22 02:09

Garth Kidd