lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, Jul 1, 2009 at 1:07 PM, Wim Paulussen<wim@asgc.be> wrote:
> I recently discovered the existence of lua and want to investigate more
> about what I could do with it.
>
> I installed Lua (5.1.4 - built on Centos ), installed luarocks and Nanoki.
> I also installed the required modules (filesystem, luasocket, lzlib and
> slncrypto) . 'luarocks list' displays these modules as installed. so far,
> I did not get any error messages, so I assumed everything is OK.
>
> When trying to launch Nanoki, I get the following 'lua:
> ./TCPServer.lua:15: module 'socket' not found: ....(more error messages
> about files not found) '
> As far as I can see this means that socket.lua, although present, cannot
> be found by lua.
>
> Also, I do not have a LUA_PATH variable set. Anyone able to point me in
> the right direction ?

First, check if luarocks.require is in Lua's module path. You can do
this by launching the interpreter in the command line and doing:

require("luarocks.require")

if that returns no error messages, you should be ok. (You should also
be able to do require("socket") after loading luarocks.require). If
you did a default install of Lua and LuaRocks that should be already
the case. If it fails, you should edit your LUA_PATH variable (there
should be documentation around on how to edit this, somewhere).

If you're able to load luarocks.require, then the next question is:

How did you launch the script? The luarocks.require module needs to be
loaded in order for modules to be found, so if you did

lua ./TCPServer.lua

then you should do

lua -lluarocks.require ./TCPServer.lua

and if the script is executable and you launched it with

./TCPServer.lua

then you should edit its first line from something like

#!/usr/bin/lua

to something like

#!/usr/bin/lua -lluarocks.require

Let us know if you still have problems.

-- Hisham