未找到 Luarocks 安装的模块

rns*_*nso 6 lua module luarocks

我正在研究 Debian 稳定版 Linux。我通过命令安装了 luafilesystem 模块:

luarocks --local install luafilesystem
Run Code Online (Sandbox Code Playgroud)

但是,在lua源文件中使用以下任何一种时都找不到:

require ("lfs")
require ("luafilesystem")
Run Code Online (Sandbox Code Playgroud)

(尽管这些文件在 ZeroBraneStudio IDE 中运行时可以正常运行)。

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

luarocks --local install luarocks
Run Code Online (Sandbox Code Playgroud)

但它没有帮助。我检查了 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
Run Code Online (Sandbox Code Playgroud)

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

$ 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
Run Code Online (Sandbox Code Playgroud)

为此,我应该将 /etc/luarocks/config.lua 复制到 /home/abcd/.luarocks 吗?谢谢你的帮助。

tar*_*leb 10

和环境变量控制lua查找包时搜索的路径LUA_PATHLUA_CPATH这些可能没有正确设置。通过运行将 luarocks 使用的路径包含在这些变量中

eval "$(luarocks path)"
Run Code Online (Sandbox Code Playgroud)

你应该已经准备好了。