Lua - 如何在OSX中添加路径变量

时间:2011-04-06 20:04:23

标签: lua environment-variables

有人可以列出我需要在我的系统上放置lua文件(theclass.lua)的步骤,以便我可以这样做:

require 'theclass'

并且编译器可以在不必将类复制到每个目录的情况下找到它吗?

1 个答案:

答案 0 :(得分:3)

如果收到错误消息,您可以将其放置的位置列表:

~ e$ lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> require 'theclass'
stdin:1: module 'theclass' not found:
no field package.preload['theclass']
no file './theclass.lua'
no file '/usr/local/share/lua/5.1/theclass.lua'
no file '/usr/local/share/lua/5.1/theclass/init.lua'
no file '/usr/local/lib/lua/5.1/theclass.lua'
no file '/usr/local/lib/lua/5.1/theclass/init.lua'
no file './theclass.so'
no file '/usr/local/lib/lua/5.1/theclass.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'require'
stdin:1: in main chunk
[C]: ?
> 

Lua至少要查询三个地方的搜索目录列表:

配置标题中的C LUA_PATH

Lua全球LUA_PATH

环境变量LUA_PATH

请参阅PiL