Override Mushclient's luasocket

Posted by Candido on Wed 21 Dec 2011 01:08 PM — 3 posts, 15,214 views.

USA #0
Hello,

I am trying to get a mushclient world to load luasocket 2.0.2 instead of Mushclient's built in 2.0.1 because of a certain memory bug in 2.0.1.

I placed the socket.lua in my world's directory, along with the socket folder containing all the sub libraries and the core.dll. Before the requires in my script, I do a ChangeDir(GetInfo(67)) to make my world's directory the current directory.

It correctly loads socket.lua from the world directory, but then loads Mushclient's core.dll, even though it is supposedly lower priority than loading from current directory. When I delete Mushclient's core.dll, it correctly loads the one in my world's socket folder, but while Mushclient's files are in place there seems to be no way to get it to load mine first. It's already higher priority in package.path, so it doesn't look like I can get anywhere by manipulating that.

Here is my package.path

Quote:
;.\lua\?.lua;;.\?.lua;C:\Program Files (x86)\MUSHclient\lua\?.lua;C:\Program Files (x86)\MUSHclient\lua\?\init.lua;C:\Program Files (x86)\MUSHclient\?.lua;C:\Program Files (x86)\MUSHclient\?\init.lua;C:\Program Files (x86)\Lua\5.1\lua\?.luac


Here is my package.cpath

Quote:
.\?.dll;C:\Program Files (x86)\MUSHclient\?.dll;C:\Program Files (x86)\MUSHclient\loadall.dll


And here is a traceback for doing a require "socket.x" (the real command is require "socket.core")

Quote:
Immediate execution
module 'socket.x' not found:
no field package.preload['socket.x']
no file '.\lua\socket\x.lua'
no file '.\socket\x.lua'
no file 'C:\Program Files (x86)\MUSHclient\lua\socket\x.lua'
no file 'C:\Program Files (x86)\MUSHclient\lua\socket\x\init.lua'
no file 'C:\Program Files (x86)\MUSHclient\socket\x.lua'
no file 'C:\Program Files (x86)\MUSHclient\socket\x\init.lua'
no file 'C:\Program Files (x86)\Lua\5.1\lua\socket\x.luac'
no file '.\socket\x.dll'
no file 'C:\Program Files (x86)\MUSHclient\socket\x.dll'
no file 'C:\Program Files (x86)\MUSHclient\loadall.dll'
no file '.\socket.dll'
no file 'C:\Program Files (x86)\MUSHclient\socket.dll'
no file 'C:\Program Files (x86)\MUSHclient\loadall.dll'
stack traceback:
[C]: in function 'require'
[string "Command line"]:1: in main chunk


Everything seems to say it should load from the socket folder in the current directory first, but this is not the case. Is there anything I can do to work around this without changing Mushclient's files? Alternatively, officially upgrading Mushclient's luasocket to 2.0.2 would be great too. :)
Australia Forum Administrator #1
I'm not sure what you mean by Mushclient's core.dll.

There are (confusingly) two core.dll files supplied with LuaSocket. One goes into the mime subdirectory and one into the socket subdirectory. If you replace both of them with the correct ones from the download, and replace all the .lua files with the ones of the same name from the download, it should work. It did for me.

Anyway, version 4.81 will have LuaSocket 2.0.2 as you suggested.
USA #2
Wow, I didn't even notice there was a second core. Still, it doesn't seem to help any. If you mean replace Mush's .lua files and dll's, then yes that does work. What I was trying to do though was make it load a copy of luasocket from the world's directory instead from mushclient's. That way I could deploy the world on other computers without any assumptions about their installation. This didn't work because somehow it was defying the package.path ordering, but if 4.81 will have it, then I'm not going to lose any sleep over it.