简体   繁体   English

Windows上的LUAROCKS奇怪地安装了岩石

[英]LUAROCKS on windows installs rocks oddly

On Linux, luarocks installs rocks to 在Linux上,luarocks会将岩石安装到

/usr/local/lib/luarocks/rock

and puts a corresponding lua file into 并将相应的lua文件放入

/usr/local/share/lua/5.3

On Windows(LUA 5.1), the rocks are in: 在Windows(LUA 5.1)上,岩石位于:

C:\Program Files (x86)\LuaRocks\systree\lib\luarocks

and the lua files are in: lua文件位于:

C:\Program Files (x86)\LuaRocks\systree\share\lua\5.1

but lua cannot find them on the windows install. 但是lua在Windows安装中找不到它们。

I must have a PATH problem 我一定有路径问题

This is some of my PATH: 这是我的一些路径:

Path=C:\Program Files (x86)\Lua\5.1\lua\;C:\Program Files (x86)\LuaRocks\2.2;C:\Program Files (x86)\LuaRocks\2.2\lua\luarocks;C:\Program Files (x86)\LuaRocks\systree\bin;C:\Perl64\site\bin;C:\UnxUpdts;C:\Perl64\bin;C:\Program Files (x86)\Lua\5.1;C:\Program Files (x86)\Lua\5.1\clibs

I am trying ZeroBraneStudio as the IDE and my system prefs specify this path 我正在尝试ZeroBraneStudio,因为IDE和我的系统偏好指定了此路径

path.lua = 'C:\Program Files (x86)\Lua\5.1'

I ran 我跑了

luarocks install inspect

and that generated the necessary files. 然后生成了必要的文件。 Then I wrote this simple test code: 然后,我编写了这个简单的测试代码:

require "inspect"
assert(inspect(1) == "1")
assert(inspect("Hello") == '"Hello"')

and got this error 并得到这个错误

Program starting as '"E:\Anonamouse\ZeroBraneStudio\bin\lua.exe" -e "io.stdout:setvbuf('no')" "E:\Anonamouse\ZeroBraneStudio\myprograms\DemoInspectModule.lua"'.
Program 'lua.exe' started in 'E:\Anonamouse\ZeroBraneStudio\myprograms' (pid: 14776).
E:\Anonamouse\ZeroBraneStudio\bin\lua.exe: ...namouse\ZeroBraneStudio\myprograms\DemoInspectModule.lua:2: attempt to call global 'inspect' (a nil value)
stack traceback:
        ...namouse\ZeroBraneStudio\myprograms\DemoInspectModule.lua:2: in main chunk
        [C]: at 0x00402a57
Program completed in 0.04 seconds (pid: 14776).

I get the same error when I execute the same simple app directly in the console.(That tells me that PATH variable for lua is working) 当我直接在控制台中执行相同的简单应用程序时,会遇到相同的错误。(这告诉我lua的PATH变量正在工作)

What am I missing? 我想念什么?

Judging from the error message you quoted the require "inspect" worked just fine, but the module didn't set a global variable inspect . 从错误消息中判断,您引用了require "inspect"效果很好,但是模块未设置全局变量inspect For some time now it has been policy to not set globals from within modules, but instead return something (usually the module table) from the module code, which in turn gets passed down via require . 一段时间以来,一直的策略是从模块内部设置全局变量,而是从模块代码返回某些内容(通常是模块表),然后再通过require向下传递。 So probably something like 所以大概像

local inspect = require "inspect"
assert(inspect(1) == "1")
assert(inspect("Hello") == '"Hello"')

or 要么

local inspect = require "inspect"
assert(inspect.inspect(1) == "1")
assert(inspect.inspect("Hello") == '"Hello"')

should work. 应该管用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM