7

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

我试过附加lua的package.path,但没有骰子。LuaJIT 似乎找不到任何岩石,这很奇怪。我应该在这里做什么?

4

4 回答 4

7

如果您使用 luarocks 安装了模块,但不是以 root 身份安装,请坚持: require 'luarocks.loader' 在您包含模块之前,它应该被包含在没有错误的情况下。

于 2011-07-24T19:38:57.493 回答
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:~$ 
于 2011-07-24T11:50:59.237 回答
2

在 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"))'
于 2015-10-02T00:54:39.887 回答
1

在编译 LuaJIT 之前,将 src/luaconf.h 中的 LUA_ROOT 从 /usr/local 更改为 /usr。

于 2011-07-25T03:51:24.940 回答