【问题标题】:Module installed by Luarocks not found未找到 Luarocks 安装的模块
【发布时间】:2018-04-10 18:47:27
【问题描述】:

我正在开发 Debian 稳定版 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 吗?感谢您的帮助。

【问题讨论】:

  • 你先require "luarocks.loader" 吗?
  • 我使用 sudo luarocks install luafilesystem 安装了模块(没有 --local 选项)并且它可以工作。那么本地安装的模块需要luarocks.loader吗?

标签: module lua luarocks


【解决方案1】:

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

eval "$(luarocks path)"

你应该准备好了。

【讨论】:

    猜你喜欢
    • 2019-09-11
    • 2014-10-25
    • 2018-10-23
    • 2021-02-22
    • 1970-01-01
    • 2014-08-25
    • 1970-01-01
    • 1970-01-01
    • 2012-03-05
    相关资源
    最近更新 更多