LuaJIT not seeing rocks installed by LuaRocks
Asked Answered
S

4

7

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?

Sauerkraut answered 23/7, 2011 at 22:1 Comment(1)
Did you install the rocks as root?Raynell
R
2

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:~$ 
Raynell answered 24/7, 2011 at 11:50 Comment(1)
Thanks Doug, I looked at the other suggestions... and they all looked like they would work, but were suboptimal, as I did not want to modify my code, or the LuaJIT package.Sauerkraut
F
7

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.

Floridafloridia answered 24/7, 2011 at 19:38 Comment(0)
R
2

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:~$ 
Raynell answered 24/7, 2011 at 11:50 Comment(1)
Thanks Doug, I looked at the other suggestions... and they all looked like they would work, but were suboptimal, as I did not want to modify my code, or the LuaJIT package.Sauerkraut
T
2

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"))'
Thoughtless answered 2/10, 2015 at 0:54 Comment(0)
B
1

Before you compile LuaJIT, change LUA_ROOT from /usr/local to /usr in src/luaconf.h.

Blub answered 25/7, 2011 at 3:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.