minetest-mods / irc

IRC Mod for Minetest
BSD 2-Clause "Simplified" License
43 stars 31 forks source link

module 'socket.core' not found #29

Closed YuGiOhJCJ closed 7 years ago

YuGiOhJCJ commented 7 years ago

Hello,

On Slackware64 14.2, I am using:

And here is what happens:

$ minetest 
2016-10-08 14:35:22: WARNING[Main]: Couldn't find a locale directory!
Loaded texture: /usr/share/minetest/games/minetest_game/menu/header.png
Loaded texture: /usr/share/minetest/games/minetest_game/menu/icon.png
Loaded texture: /usr/share/minetest/games/minimal/menu/icon.png
2016-10-08 14:35:25: WARNING[Main]: NodeDefManager: Ignoring CONTENT_IGNORE redefinition
2016-10-08 14:35:25: ERROR[Main]: ModError: Failed to load and run script from /home/yugiohjcj/.minetest/mods/minetestirc/init.lua:
2016-10-08 14:35:25: ERROR[Main]: /usr/share/lua/5.1/socket.lua:12: module 'socket.core' not found:
2016-10-08 14:35:25: ERROR[Main]:   no field package.preload['socket.core']
2016-10-08 14:35:25: ERROR[Main]:   no file '/home/yugiohjcj/.minetest/mods/minetestirc/socket/core/init.lua'
2016-10-08 14:35:25: ERROR[Main]:   no file '/home/yugiohjcj/.minetest/mods/minetestirc/socket/core.lua'
2016-10-08 14:35:25: ERROR[Main]:   no file './socket/core.lua'
2016-10-08 14:35:25: ERROR[Main]:   no file '/usr/local/share/lua/5.1/socket/core.lua'
2016-10-08 14:35:25: ERROR[Main]:   no file '/usr/local/share/lua/5.1/socket/core/init.lua'
2016-10-08 14:35:25: ERROR[Main]:   no file '/usr/local/lib/lua/5.1/socket/core.lua'
2016-10-08 14:35:25: ERROR[Main]:   no file '/usr/local/lib/lua/5.1/socket/core/init.lua'
2016-10-08 14:35:25: ERROR[Main]:   no file '/usr/share/lua/5.1/socket/core.lua'
2016-10-08 14:35:25: ERROR[Main]:   no file '/usr/share/lua/5.1/socket/core/init.lua'
2016-10-08 14:35:25: ERROR[Main]:   no file './socket/core.so'
2016-10-08 14:35:25: ERROR[Main]:   no file '/usr/local/lib/lua/5.1/socket/core.so'
2016-10-08 14:35:25: ERROR[Main]:   no file '/usr/local/lib/lua/5.1/loadall.so'
2016-10-08 14:35:25: ERROR[Main]:   no file '/usr/lib/lua/5.1/socket/core.so'
2016-10-08 14:35:25: ERROR[Main]:   no file './socket.so'
2016-10-08 14:35:25: ERROR[Main]:   no file '/usr/local/lib/lua/5.1/socket.so'
2016-10-08 14:35:25: ERROR[Main]:   no file '/usr/local/lib/lua/5.1/loadall.so'
2016-10-08 14:35:25: ERROR[Main]:   no file '/usr/lib/lua/5.1/socket.so'
2016-10-08 14:35:25: ERROR[Main]: stack traceback:
2016-10-08 14:35:25: ERROR[Main]:   [C]: in function 'require'
2016-10-08 14:35:25: ERROR[Main]:   /usr/share/lua/5.1/socket.lua:12: in main chunk
2016-10-08 14:35:25: ERROR[Main]:   [C]: in function 'require'
2016-10-08 14:35:25: ERROR[Main]:   ...home/yugiohjcj/.minetest/mods/minetestirc/irc/init.lua:1: in main chunk
2016-10-08 14:35:25: ERROR[Main]:   [C]: in function 'require'
2016-10-08 14:35:25: ERROR[Main]:   /home/yugiohjcj/.minetest/mods/minetestirc/init.lua:36: in main chunk
2016-10-08 14:35:25: ERROR[Main]: Check debug.txt for details.

What am I doing wrong please?

Thank you. Best regards.

ShadowNinja commented 7 years ago

It looks like your luasocket installation is somehow broken, luasocket can't find a part of itself. You'll have to find out where luasocket's socket.so or core.so file is (probably somewhere like /usr/lib/lua/5.1) and make sure that its added to Lua's native search path (package.cpath).

YuGiOhJCJ commented 7 years ago

OK, so here is the location of core.so:

$ find /usr/lib64/lua -name "core.so"
/usr/lib64/lua/5.1/mime/core.so
/usr/lib64/lua/5.1/socket/core.so

But there is no socket.so. Is it normal?

And here is the current value of my Lua's native search path (package.cpath):

$ lua
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> return package.cpath
./?.so;/usr/lib64/lua/5.1/?.so;/usr/lib64/lua/5.1/loadall.so
> ^C

So, what I did is to edit the init.lua file of the irc mod to add this first line:

package.cpath = package.cpath .. ";/usr/lib64/lua/5.1/socket/?.so"

But it does not help. I get the same error. Is it the good way to change my Lua's native search path (package.cpath)?

kaeza commented 7 years ago

You should use /usr/lib64/lua/5.1/?.so instead of /usr/lib64/lua/5.1/socket/?.so (i.e. provide the path to the root of the Lua lib dir). LuaSocket requires the module socket.core, so it should resolve to /usr/lib64/lua/5.1/socket/core.so. Make those changes in the mod's init.lua.

From your examples, it seems Minetest is looking for /usr/lib/... while the standalone Lua interpreter is looking for /usr/lib64/...; it's possible Minetest is not using the system-wide Lua and is using the bundled one which is using the default paths (i.e. not ones specially configured for your system).

YuGiOhJCJ commented 7 years ago

The two things you said were correct.

1) Editing the init.lua file of the irc mod to add this first line solves the problem:

package.cpath = package.cpath .. ";/usr/lib64/lua/5.1/?.so"

2) My Minetest was built with the bundled Lua because LuaJIT was not installed on my system. Rebuilding Minetest after installing LuaJIT on my system solves the problem. Now, Minetest is installed with the system Lua instead of the bundled one. It means that I don't need anymore to edit the init.lua file of the irc mod now because the package.cpath value is correct :)

Problem solved.