“module 'socket.http' not found:” --Lua on iMac

Alex picture Alex · May 10, 2013 · Viewed 13k times · Source

When I run my code in terminal, I get this error/message:

module 'socket.http' not found: 
    no field package.preload['socket.http'] 
    no file '/usr/local/share/lua/5.2/socket/http.lua' 
    no file '/usr/local/share/lua/5.2/socket/http/init.lua' 
    no file '/usr/local/lib/lua/5.2/socket/http.lua' 
    no file '/usr/local/lib/lua/5.2/socket/http/init.lua' 
    no file './socket/http.lua' 
    no file '/usr/local/lib/lua/5.2/socket/http.so' 
    no file '/usr/local/lib/lua/5.2/loadall.so' 
    no file './socket/http.so' 
    no file '/usr/local/lib/lua/5.2/socket.so' 
    no file '/usr/local/lib/lua/5.2/loadall.so' 
    no file './socket.so'

Some sources led me to look into LuaSocket, but I still have no idea on what to do or how I would install that.

Answer

hjpotter92 picture hjpotter92 · May 11, 2013

There are several places where a guide to install LuaSocket is available. Some of them are listed as follows:

My preferred method would be to install LuaRocks and then use the following command in terminal:

luarocks install luasocket