How to configure LUA_PATH?

Asked

Viewed 326 times

2

I installed the IUP (Toolkit graphic) in a given folder. When I run the following script from within that folder, it works perfectly..

require("iuplua")
iup.Message('Minha Aplicação','Finalizada com sucesso!')

The iuplua.so file is a shortcut that points to /usr/lib/libiuplua52.so. This file exists in the installation directory and there is a copy in /usr/lib/lua/5.2/iuplua.so

The problem happens when I leave this directory and try to run the same application, I get this error message:

    lua: error loading module 'iuplua' from file './iuplua.lua':
    ./iuplua.lua:142: too many C levels (limit is 200) in main function near '"Toggle Text"'
stack traceback:
[C]: in ?
[C]: in function 'require'
./iuplua.lua:1: in main chunk
[C]: in function 'require'
./iuplua.lua:1: in main chunk
[C]: in function 'require'
./iuplua.lua:1: in main chunk
[C]: in function 'require'
./iuplua.lua:1: in main chunk
[C]: in function 'require'
...

If I check the search path inside the Lua interpreter:

> print (package.cpath)
/usr/local/lib/lua/5.2/?.so;/usr/lib/i386-linux-gnu/lua/5.2/?.so;/usr/lib/lua/5.2/?.so;/usr/local/lib/lua/5.2/loadall.so;./?.so

I’m not very experienced in GNU-Linux, but it seems to me a problem in the search path... the so-called LUA_PATH... is that right? Someone knows how to fix this?

1 answer

2


the problem was ridiculously simple....

I actually created a test script called iuplua.moon. This choice of name was unfortunate because the require required a file iuplua.. However the search engine of the moon (lua_path) first found the file (of the same name) with extension moon:

/usr/local/share/lua/5.2/?.lua;/usr/local/share/lua/5.2/?/init.lua;/usr/local/lib/lua/5.2/?.lua;/usr/local/lib/lua/5.2/?/init.lua;/usr/share/lua/5.2/?.lua;/usr/share/lua/5.2/?/init.lua;./?.lua

(note the last option: "./?.moon"!)

Hence my testing program was mistaken for the library .only and the program mentioned in the question was not executed.

  • 1

    If I’m not mistaken, now that it’s been a few days you can mark your own answer as you accept.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.