无法运行luarocks,tonumber是零值

时间:2012-10-08 15:32:02

标签: macos lua luarocks

要安装luarocks,我从here下载了最新的(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和其他一切一样正常。我不知道为什么它在这里失败了。

1 个答案:

答案 0 :(得分: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")