Search code examples
macossocketslualuasocket

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


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.


Solution

  • 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