$ sudo port -v install lua luarocks
I installed LuaSocket.
$ sudo luarocks install luasocket
I was under the mistaken impression that when I tried to run some example code, the ENVIRONMENT would be setup and functioning properly. Unfortunately this was not the case:
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> require "sockets"
/opt/local/share/lua/5.1/luarocks/require.lua:256: module 'sockets' not found:
no field package.preload['sockets']
no file './sockets.lua'
no file '/opt/local/share/lua/5.1/sockets.lua'
no file '/opt/local/share/lua/5.1/sockets/init.lua'
no file '/opt/local/lib/lua/5.1/sockets.lua'
no file '/opt/local/lib/lua/5.1/sockets/init.lua'
no file './sockets.so'
no file '/opt/local/lib/lua/5.1/sockets.so'
no file '/opt/local/lib/lua/5.1/loadall.so'
[C]: in function 'plain_require'
/opt/local/share/lua/5.1/luarocks/require.lua:256: in function 'require'
stdin:1: in main chunk
After some investigation I'd realized that the LUA_PATH wasn't set up by the packages that were installed. Since I'd installed the LuaSocket package as the administrator (with the sudo command). I needed to include the system-wide path to the rocks libraries. I did this for my user only by editing my .kshrc file. If I'd wanted to do the same thing in bash I could have used .bshrc or .bashrc. To do it for every user of the system I could have use /etc/profile and /etc/login. In any case I put in this line:
After that was included everything ran fine (don't forget to reload your environment.