4

I am using lua 5.1 in a linux system.I installed the luasocket 2.0.2 using this manual.But when i execute the below code of the file test.lua

socket = require("socket")
print(socket._VERSION)

I get the following errors :

lua: ./usr/local/share/lua/5.1/socket.lua:14: loop or previous error loading module 'socket'

stack traceback:

    [C]: in function 'require'

    ./usr/local/share/lua/5.1/socket.lua:14: in main chunk

    [C]: in function 'require'

    test.lua:1: in main chunk

    [C]: ?

But i have included the environmental variable as below:

LUA_PATH=/usr/local/share/lua/5.1/?.lua;?.lua

LUA_CPATH=/usr/local/lib/lua/5.1/?.so;?.so
Jaffa
  • 12,442
  • 4
  • 49
  • 101

1 Answers1

2

You usually get this error when you have a loop in your require calls, for example, when you do require "socket" and from that module you do require "socket" again, before the first require call is finished.

Check line 14 in socket.lua file. It should probably have something like local socket = require("socket.core") (and not require("socket")). To check if the issue is with loading socket.core, try executing require "socket.core" in your own script as it may give you a better error message.

Paul Kulchenko
  • 25,884
  • 3
  • 38
  • 56
  • 1
    bt now there is an error "error loading module 'socket.core' from file '/usr/local/lib/lua/5.1/socket/core.so': /usr/local/lib/lua/5.1/socket/core.so: undefined symbol: luaL_getmetatable" –  Jun 06 '14 at 04:21
  • 1
    You may want to check this SO question and the first answer: http://stackoverflow.com/questions/8361437/linker-error-lunatic-python-lua-requiresocket-undefined-symbol-lua-getme – Paul Kulchenko Jun 06 '14 at 21:27