require "compat-5.1" problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

require "compat-5.1" problem

Bernd Kronmueller
Hello,
I am just fighting with require.

Here is a very short program (chunk1.lua):

require("compat-5.1")
print("chunk1 start")

strangely (at least I think it is strange) this results in the following
error message:

[bernd@impact36 lua_lib]$ lua chunk1.lua
lua: chunk1.lua:1: cannot find compat-5.1 in
path /madras/bernd/impact4-t/lua/lua_lib/?.lua;?.lua;/madras/bernd/impact4-t/lua/lua_lib/socket/?.lua;/madras/bernd/impact4-t/lua/lua_lib/logging/?.lua
stack traceback:
        [C]: in function `error'
        /madras/bernd/impact4-t/lua/lua_lib/compat-5.1.lua:70: in
function `require'
        chunk1.lua:1: in main chunk
        [C]: ?
[bernd@impact36 lua_lib]$

The error actually comes out of the file it claims not to find??
/madras/bernd/impact4-t/lua/lua_lib/compat-5.1.lua:70 which is I guess
in /madras/bernd/impact4-t/lua/lua_lib/?.lua

 Oh yes, environment:

LUA_CPATH='/madras/bernd/impact4-t/lua/c_lib/?.so;?.so'
LUA_INIT=@/madras/bernd/impact4-t/lua/lua_lib/compat-5.1.lua
LUA_PATH='/madras/bernd/impact4-t/lua/lua_lib/?.lua;?.lua;/madras/bernd/impact4-t/lua/lua_lib/socket/?.lua;/madras/bernd/impact4-t/lua/lua_lib/logging/?.lua'
LUA_PATHLIB='/madras/bernd/impact4-t/lua/c_lib/?.so;?.so'


Yes I know, LUA_INIT has it already but I try to figure out why some of
our lua libraries which are required twice (because of dofile) actually
work the first time round but fail the second time round (even if
_LOADED says it is loaded already).  

Am I just missing something here??

Cheers,
        Bernd

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: require "compat-5.1" problem

Alex Queiroz
Hallo,

On 5/31/06, Bernd Kronmueller <[hidden email]> wrote:
>
> Am I just missing something here??
>

     I don't use compat, but i think you are not meant to require()
it, because compat is exactly the package that brings the module
system to Lua 5.0.


--
-alex
http://www.ventonegro.org/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: require "compat-5.1" problem

Tomas-14
In reply to this post by Bernd Kronmueller
  Hi Bernd

> Yes I know, LUA_INIT has it already but I try to figure out why some of
> our lua libraries which are required twice (because of dofile) actually
> work the first time round but fail the second time round (even if
> _LOADED says it is loaded already).
>
> Am I just missing something here??
  The bug is that compat-5.1.lua should register itself, like:

package.loaded["compat-5.1"] = true

  Sorry about that.  You could add that line somewhere in the
file.  You could check for _COMPAT51 global variable, which is defined
by the file, and decide if you have to require it or not.

  Tomas
Loading...