[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Installing Lua and add-ons
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 10 Apr 2012 10:50:46 +0200
On Mon, Apr 9, 2012 at 6:17 PM, Jose Torre-Bueno <jtorrebueno@cox.net> wrote:
> know that basically any directory structure can be set up but Lua and its
> add-ons seem to have some standard structure as the default and
> understanding that would help also.
The cool thing is the error messages tell you exactly where Lua is
expecting to find modules; this is a Debian system, but the same
principles apply. When Lua requires a module, it will look in the
path contained in package.path, which is always semi-colon separated;
the ? is replaced by the module name. The error trace when you fail
to load a module tells you exactly where Lua has looked for the Lua
file, and if it fails, it starts looking for C extensions (which are
also .so on Mac OS).
/mnt/extra/lua/luabuild$ lua
Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio
> require 'pedro'
stdin:1: module 'pedro' not found:
no field package.preload['pedro']
no file './pedro.lua'
no file '/usr/local/share/lua/5.1/pedro.lua'
no file '/usr/local/share/lua/5.1/pedro/init.lua'
no file '/usr/local/lib/lua/5.1/pedro.lua'
no file '/usr/local/lib/lua/5.1/pedro/init.lua'
no file './pedro.so'
no file '/usr/local/lib/lua/5.1/pedro.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
> = package.path
;./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua;/home/sdonovan/projects/lua/lua/?.lua;/home/sdonovan/projects/lua/lua/?/init.lua
> = package.cpath
./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so
>
If you had pedro.lua somewhere, you now know that you must copy it to
/usr/local/share/lua/5.1 for require() to find it.
steve d.