luasocket
luasocket copied to clipboard
[macos]. openresty symbol not found in flat namespace '_luaL_prepbuffsize'
[macos]. openresty symbol not found in flat namespace '_luaL_prepbuffsize'
openresty -c nginx-debug.conf
error info
2022/03/25 16:54:11 [error] 34351#0: *4 lua entry thread aborted: runtime error: error loading module 'socket.core' from file '/usr/local/lib/lua/5.4/socket/core.so':
dlopen(/usr/local/lib/lua/5.4/socket/core.so, 0x0006): symbol not found in flat namespace '_luaL_prepbuffsize'
stack traceback:
coroutine 0:
[C]: in function 'require'
...nresty-1.19.9.1/bin/nginx/lua-resty-access-pass/test.lua:9: in main chunk, client: 127.0.0.1, server: localhost, request: "GET /test/debug HTTP/1.1", host: "localhost:1010"
2022/03/25 16:54:11 [error] 34351#0: *4 lua entry thread aborted: runtime error: error loading module 'socket.core' from file '/usr/local/lib/lua/5.4/socket/core.so':
dlopen(/usr/local/lib/lua/5.4/socket/core.so, 0x0006): symbol not found in flat namespace '_luaL_prepbuffsize'
stack traceback:
coroutine 0:
[C]: in function 'require'
...nresty-1.19.9.1/bin/nginx/lua-resty-access-pass/test.lua:9: in main chunk, client: 127.0.0.1, server: localhost, request: "GET /test/debug HTTP/1.1", host: "localhost:1010"
2022/03/25 16:54:11 [error] 34351#0: *4 lua entry thread aborted: runtime error: error loading module 'socket.core' from file '/usr/local/lib/lua/5.4/socket/core.so':
dlopen(/usr/local/lib/lua/5.4/socket/core.so, 0x0006): symbol not found in flat namespace '_luaL_prepbuffsize'
stack traceback:
coroutine 0:
[C]: in function 'require'
...nresty-1.19.9.1/bin/nginx/lua-resty-access-pass/test.lua:9: in main chunk, client: 127.0.0.1, server: localhost, request: "GET /test/debug HTTP/1.1", host: "localhost:1010"
please help me, thank you.
What version of LuaSocket are you using? How did you build & install it? Are you sure you built it against the same Lua headers as the version of Lua you are running?
Happy to look into this if there are further details and you can answer questions. It still seems like this is a miss-match between the headers you are building against and the Lua you are running. Comment back with info if there is still something that needs addressing here.
I got the same problem on my Mac too.
2024/01/25 16:23:36 [error] 30771#476790: *4 lua entry thread aborted: runtime error: error loading module 'socket.core' from file './socket/core.so': dlopen(./socket/core.so, 0x0006): symbol not found in flat namespace '_luaL_prepbuffsize'
I install LuaSocket 3.1.0-1 via luarocks with following command: luarocks install luasocket Lua version: 5.4.3 Mac version: macOS Sonoma 14.2.1
@tenpend How is your error related to OpenResty? What command or code are you running that shows that error? If it isn't OpenResty related please open a new issue report for your situation.
Yes, I'm running my code inside openresty.
Full error stack is:
2024/01/25 16:23:36 [error] 30771#476790: *4 lua entry thread aborted: runtime error: error loading module 'socket.core' from file './socket/core.so': dlopen(./socket/core.so, 0x0006): symbol not found in flat namespace '_luaL_prepbuffsize' stack traceback: coroutine 0: [C]: in function 'require' ...openenresty//lua/vendor/libs/util/common_util.lua:21: in function 'GetLocalIP' ...vendor/libs/agollo/repository/remoteApolloRepository.lua:155: in function 'AssembleURL' ...vendor/libs/agollo/repository/remoteApolloRepository.lua:51: in function 'GetConfigOriginData' ...openresty//lua/vendor/libs/agollo/config.lua:68: in function 'initialize' ...openresty//lua/vendor/libs/agollo/config.lua:23: in function 'new' ...openresty//lua/vendor/libs/agollo/configFactory.lua:19: in function 'GetConfigByNameSpace' ...openresty//lua/vendor/libs/agollo/configService.lua:28: in function 'GetConfig' ...openresty//lua/util.lua:19: in function 'get_redis_connection' ...openresty//lua/redis_notifier.lua:12: in function <... openresty/lua/redis_notifier.lua:11>, context: ngx.timer
code is:
function _M.GetLocalIP()
if localIP then
return localIP
end
local socket = require("socket")
local function GetAdd(hostname)
local ip, resolved = socket.dns.toip(hostname)
local ListTab = {}
if resolved and "table" == type(resolved) then
for k, v in ipairs(resolved.ip) do
table.insert(ListTab, v)
end
end
return ListTab
end
local ip = GetAdd(socket.dns.gethostname())
if ip and "table" == type(ip) and next(ip) and unpack(ip) then
localIP = unpack(ip)
return localIP
else
localIP = "127.0.0.1"
end
return "127.0.0.1"
end