0

为了安装 luarocks,我从这里下载了最新的 (2.0.11) tar.gx 文件。我打开它,并按照说明进行操作。

$ ./configure 
Lua interpreter found: /usr/local/bin/lua...
Lua version detected: 5.1
Looking for Lua... 
lua found in $PATH: /usr/local/bin
Checking Lua includes... 
lua.h found in /usr/local/include/lua.h
curl found at /usr/bin
openssl found at /opt/local/bin
Configuring for system... 
Darwin
Configuring for architecture... 
i386
Writing configuration...

Installation prefix: /usr/local
LuaRocks configuration directory: /usr/local/etc/luarocks
Using Lua from: /usr/local

Done. You can now run 'make' to build.

然后我跑了sudo make install,最后尝试安装一个包,但是当我尝试运行它时,我收到了这个错误:

$ sudo luarocks install lpeg
/usr/local/bin/lua: /usr/local/share/lua/5.1//luarocks/cfg.lua:355: attempt to call global 'tonumber' (a nil value)
stack traceback:
    /usr/local/share/lua/5.1//luarocks/cfg.lua:355: in main chunk
    [C]: in function 'require'
    /usr/local/share/lua/5.1//luarocks/command_line.lua:6: in main chunk
    [C]: in function 'require'
    /usr/local/bin/luarocks:4: in main chunk
    [C]: ?

手动运行 lua,tonumber 和其他所有东西一样工作得很好。我不知道为什么它在这里失败。

4

1 回答 1

3

在 cfg.lua 的顶部,您需要添加

local tonumber = tonumber

通话前module。您可以tonumber在相似的本地定义列表的两行中包括。您可以在 /usr/local/share/lua/5.1//luarocks/cfg.lua 或源版本中的已安装版本中进行这些更改,然后make install再一次。

这是 luarocks 中的一个错误,将在下一个版本中修复。

我修改后的 luarocks-2.0.11/src/luarocks/cfg.lua 包含:

local rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, type, assert, tonumber, _VERSION =
      rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, type, assert, tonumber, _VERSION

module("luarocks.cfg")
于 2012-10-08T16:48:43.360 回答