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 /本地/共享/ LUA / 5.1 /?/ init.lua
我尝试添加lua的package.path,但没有骰子。 LuaJIT似乎无法找到任何岩石,这很奇怪。我该怎么办?
答案 0 :(得分:7)
如果您使用luarocks安装模块,但不是root用户,请坚持:
require 'luarocks.loader'
在包含模块之前,应该包含它而不会出现错误。
答案 1 :(得分:2)
两个建议:
1. Install rocks as root to get them in /usr/local
2. Use ldconfig to update shared library cache
示例:
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:~$
答案 2 :(得分:1)
在编译LuaJIT之前,将/ usr / local中的LUA_ROOT更改为src / luaconf.h中的/ usr。
答案 3 :(得分:1)
在Mac上?正在运行brew
?
安装lua51
,其luarocks
别名为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"))'