under MAC OS Sonoma 14.2.1
luaclient.lua script line 2 is:
local socket = require('socket')
When the script is run, it yields:
lua: luaclient.lua:2: module 'socket' not found:
no field package.preload['socket']
no file '/usr/local/share/lua/5.4/socket.lua'
no file '/usr/local/share/lua/5.4/socket/init.lua'
no file '/usr/local/lib/lua/5.4/socket.lua'
no file '/usr/local/lib/lua/5.4/socket/init.lua'
no file './socket.lua'
no file './socket/init.lua'
no file '/usr/local/lib/lua/5.4/socket.so'
no file '/usr/local/lib/lua/5.4/loadall.so'
no file './socket.so'
stack traceback:
[C]: in function 'require'
luaclient.lua:2: in main chunk
[C]: in ?
socket is installed here:
/Users/user_name/.luarocks/share/lua/5.4
Lua interpreter says:
Lua 5.4.7 Copyright (C) 1994-2024 Lua.org, PUC-Rio
print(package.path)
/usr/local/share/lua/5.4/?.lua;/usr/local/share/lua/5.4/?/init.lua;/usr/local/lib/lua/5.4/?.lua;/usr/local/lib/lua/5.4/?/init.lua;./?.lua;./?/init.lua
Trying:
set LUA_PATH '/Users/perryhorwich/.luarocks/share/lua/5.4/?.lua'
... in the shell, gives the same error as though LUA_PATH has no effect on the lookup for 'socket'
What am I missing?
Adding this to my code:
package.cpath ="/Users/user_name/.luarocks/lib/lua/5.4/?.so;" .. package.cpath
package.path = "/Users/user_name/.luarocks/share/lua/5.4/?.lua;" .. package.path
... worked.