【问题标题】:Trying to use LuaFileSystem on Ubuntu 10.04尝试在 Ubuntu 10.04 上使用 LuaFileSystem
【发布时间】:2013-06-10 04:07:32
【问题描述】:

我已经使用以下命令安装了 LuaFileSystem:luarocks install luafilesystem。现在我想在我的脚本中使用它,但我收到了这个错误:

[splay.sandbox] W: 要求 lfs 被拒绝 10:34:11.65(6)[splay.events] E:线程:0x93f0b20 DIE(错误:[字符串“作业代码”]:35:尝试索引本地“lfs”(一个零值)) 10:34:11.65 (6) [splay.events] E:堆栈回溯: 10:34:11.65(6)[字符串“工作代码”]:35:在函数'getHomeDirectory'中 10:34:11.65 (6) [string "job code"]:79: 在函数

我尝试将其声明为全局:lfs = require"lfs",或者只需要"lfs",甚至在函数中声明为局部:

function getHomeDirectory(position)
    local lfs = require"lfs"

    print(lfs.currentdir())
end

但我仍然得到那个错误。我还需要做些什么才能让它发挥作用?

稍后编辑:尝试使用 io 打开文件时出现与“零值”相同的错误:

local f = io.open('/home/alex/Desktop/SPLAY WORK/splay_client_commands_1.4/test1.txt', "r")

[splay.events] E: thread: 0x955f4c0 DIE (error: [string "job code"]:120: 尝试索引本地 'f' (一个 nil 值))

可能是什么问题?

【问题讨论】:

    标签: lua ubuntu-10.04


    【解决方案1】:

    通过在其周围添加assert 可以轻松调试io.open 调用。这将在 io.open 无法打开文件时打印错误消息:

    local f = assert(io.open('/home/alex/Desktop/SPLAY WORK/splay_client_commands_1.4/test1.txt', "r"))

    这个“技巧”也描述在: http://www.lua.org/pil/21.2.html

    【讨论】:

    • 我已经做到了...它说它可以打开文件。我尝试使用限制性 io,但在声明“io = require("splay.restricted_io")”时收到错误:“要求 splay.restricted_io 被拒绝”。该文件存在,对于限制性 io,它位于 init 函数中声明的文件夹中。
    • 抱歉,无法打开文件:)
    猜你喜欢
    • 2012-06-25
    • 2011-06-23
    • 2012-09-08
    • 2012-03-28
    • 2012-04-17
    • 1970-01-01
    • 2014-07-26
    • 1970-01-01
    • 2011-07-30
    相关资源
    最近更新 更多