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?
المحلول
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:~$
نصائح أخرى
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.
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"))'
Before you compile LuaJIT, change LUA_ROOT from /usr/local to /usr in src/luaconf.h.