Luarocks 安装的模块未找到

我正在 Debian Stable Linux 上工作。我通过以下命令安装了 LuaFilesystem 模块:

luarocks --local install luafilesystem

但是,当在 lua 源文件中使用以下任何一个命令时,它都找不到:

require ("lfs")
require ("luafilesystem")

(尽管这些文件在从 ZeroBraneStudio IDE 内启动时可以正常工作)。

根据网上的建议,我还运行了以下命令:

luarocks --local install luarocks

但它没有帮助。我使用 luarocks-admin 命令进行了检查,结果显示:

CONFIGURATION
    Lua version: 5.1
    Configuration files:
        System: /etc/luarocks/config.lua (ok)
        User  : /home/abcd/.luarocks/config-5.1.lua (not found)

    Rocks trees in use:
        /home/abcd/.luarocks
        /usr/local

目前,我只安装了这两个模块:

$ luarocks list

Installed rocks:
----------------

luafilesystem
   1.7.0-2 (installed) - /home/abcd/.luarocks/lib/luarocks/rocks

luarocks
   2.4.3-1 (installed) - /home/abcd/.luarocks/lib/luarocks/rocks

我应该将 /etc/luarocks/config.lua 复制到 /home/abcd/.luarocks 吗?感谢您的帮助。

点赞
用户2425163
用户2425163

LUA_PATHLUA_CPATH 环境变量控制 lua 在查找软件包时搜索的路径。这些可能没有设置正确。通过运行以下命令,在这些变量中包含 luarocks 使用的路径:

eval "$(luarocks path)"

然后你就可以全部设置好了。

2017-10-30 08:34:31