mongoose : how to "require" other module?

Skip to first unread message


Oct 29, 2013, 7:18:45 AM10/29/13
 I have try to use lfs module. My test code is here:
  mg.write('HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n')
  local l = require("lfs")
  for f in lfs.dir("/") do
I have try to compile lfs to,and put it in the same path with my code.
There is nothing in the browser,even when I delete the "require" line, there is nothing,not a error log.
In the terminal,it runs well like this:
$lua admin.lua
HTTP/1.0 200 OK
Content-Type: text/html


the is here:

$ ls
admin.lp  admin.lua  data  edit.lp  index.lp  js  list.lp  page.lp  test.lua

Who knows how to let it work? Millions of Thanks.

Ed Swift

Oct 31, 2013, 12:06:57 AM10/31/13
The Lua include path is relative to the directory you were in when you launched Mongoose (the CWD), not relative to the Lua file that actually got served up. This is sort of unexpected if you're coming from CGI, and is on my personal list of things to bug Sergey about. Not sure if it's the problem you're having here, but it could be.

Sergey Lyubka

Nov 4, 2013, 6:53:45 PM11/4/13
to mongoose-users
As it is now, mongoose has lua statically compiled in.
That means, lua code cannot load DLLs, cause those DLLs have external
unresolved symbol (I think it is luaL_register() function) that is normally
exported by lua DLL.

To make things like LFS work, Lua must NOT be statically compiled in mongoose,
but be dynamically linked as DLL instead. I plan to provide a separate build
target for that, but it's not there yet. 

You received this message because you are subscribed to the Google Groups "mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

Reply all
Reply to author
0 new messages