Preventing mushclient from using local lua installation

Posted by Victorious on Thu 09 Nov 2017 06:01 PM — 17 posts, 72,127 views.

#0
Hi,

I've installed lua 5.1 onto my own system to get luarocks for easier installation of libraries However, mushclient exploded the next time it was restarted because it was using my system's lua interpretor.

Additionally, after removing the path to lua.exe from my system path, it was still using the LUA_PATH and LUA_CPATH variables meant for my local lua install. Is there a way to stop this from happening?
Australia Forum Administrator #1
Exploded? Can you give more details?
#2
It was using my installed lua interpretor's LUA_PATH and LUA_CPATH environment variable, which I defined, so when code in mushclient tried loading modules it was not able to find it.
Australia Forum Administrator #3
It would help if you posted error messages, and preferably a minimal example to demonstrate what you are saying. I believe Fiendish uses LuaJIT in the Aardwolf distribution without any problems.

In other words, it is possible to use an external version of Lua. Lua is distributed as a standalone DLL, so it should be possible to substitute another one. As Fiendish has done.
USA Global Moderator #4
I believe Victorious has installed some other distribution of Lua.exe somewhere else, and that MUSHclient is picking up this other installation's search paths (which I assume are set as environment variables?) instead of looking only inside the MUSHclient folder, and Victorious wants MUSHclient to only look inside its own folder. I have no thoughts on this, as I work exclusively within the MUSHclient folder.
Amended on Fri 10 Nov 2017 07:11 AM by Fiendish
Australia Forum Administrator #5
You mean Lua.DLL?
#6
Yeah, Fiendish described my situation perfectly. Mushclient is picking up on information meant for my own locally installed lua distribution (outside mushclient). Apologies for not being clear. Will post errors soon, if that helps - but its just the standard error messages you get when require fails to find a module, showing you all paths its tried.
USA Global Moderator #7
Nick Gammon said:

You mean Lua.DLL?


I think I mean Lua.exe, though presumably with its own Lua.dll next to it. I think the only bit that matters here is that Victorious wants MUSHclient to never search for includes outside of its directory no matter what the operating system says. Which, I have to be honest, seems both extremely weird but also contextually pretty reasonable. This is where I go ¯\_(ツ)_/¯
Amended on Fri 10 Nov 2017 07:57 AM by Fiendish
#8
What I just did was added a LUA_PATH environment variable for my local copy of lua. And this is what happened the next time I restarted mushclient.


Immediate execution
[string "Plugin: SpellcompProducer"]:152: module 'wait' not found:
        no field package.preload['wait']
        no file 'C:\Users\vic\AppData\Roaming\luarocks\share\lua\5.1\wait.lua'
        no file 'C:\Users\vic\AppData\Roaming\luarocks\share\lua\5.1\wait\init.lua'
        no file 'c:\lua\share\lua\5.1\wait.lua'
        no file 'c:\lua\share\lua\5.1\wait\init.lua'
        no file 'C:\Lua\LuaRocks\lua\wait.lua'
        no file 'C:\Lua\LuaRocks\lua\wait.lua'
        no file 'C:\Lua\LuaRocks\lua\wait\init.lua'
        no file '.\wait.dll'
        no file 'D:\documents\mushclient\wait.dll'
        no file 'D:\documents\mushclient\loadall.dll'
stack traceback:
        [C]: in function 'require'


So it is using my LUA_PATH environment variable instead of its own default one for package.path. Lua.exe is also not in my path.
Australia Forum Administrator #9
Victorious said:

... instead of its own default one ...


What is the "it" in that sentence? I think we are talking at cross-purposes. Nothing has "exploded". You are using your own DLL which appears to be respecting your own environment variables. I'm not sure what it is doing that it shouldn't be.
USA Global Moderator #10
Nick Gammon said:

Victorious said:

... instead of its own default one ...


What is the "it" in that sentence? I think we are talking at cross-purposes. Nothing has "exploded". You are using your own DLL which appears to be respecting your own environment variables. I'm not sure what it is doing that it shouldn't be.


Victorious wants MUSHclient's Lua DLL to not know about the LUA_PATH system environment variable. The "own DLL" here is, as I understand it, somewhere else, and not associated with MUSHclient.


So there's...

C:\MUSHclient\Lua5.1.dll

And there's...

C:\SomeOtherPath\Lua5.3.dll

which is used by

C:\SomeOtherPath\Lua5.3.exe

And there's...

LUA_PATH=C:\SomeOtherPath\libs;C:\SomeOtherPath\lua

or whatever



And the complaint is that C:\MUSHclient\MUSHclient.exe with its linked C:\MUSHclient\Lua5.1.dll is digging around in C:\SomeOtherPath instead of staying confined to C:\MUSHclient

And the reason for the complaint is that C:\SomeOtherPath\lua has code for Lua 5.3 that doesn't work in Lua 5.1, or maybe uses a different library called "bit" which seems to cause a name collision with MUSHclient's included bit library, or some other problem of a similar nature.

Victorious, is that correct?
Amended on Fri 10 Nov 2017 09:51 PM by Fiendish
Australia Forum Administrator #11
I don't think MUSHclient changes the LUA_PATH variable in any way. Can you show where it does?
USA Global Moderator #12
I think, if I'm understanding this right, that Victorious basically wants these #defines to be made more MUSHclient-specific. Assuming also that they do what I think they do.
https://github.com/nickgammon/mushclient/blob/master/luaconf.h#L69
Amended on Sat 11 Nov 2017 03:31 PM by Fiendish
Australia Forum Administrator #13
You mean line 90?

But ... if the defines there are the same as your own compiled defines would be, why do they need to be changed? In any case, since the Lua code is not compiled into MUSHclient, it won't reference those defines anywhere.

Nowhere in MUSHclient is LUA_PATH referenced or changed. It is just something in luaconf.h which is used when compiling Lua. Now if you use your own Lua compile they won't be used at all.

It sounds like Victorious may need to set LUA_PATH early on in using Lua, for example in Global Preferences -> Lua -> Preliminary code.
Australia Forum Administrator #14
Possibly it might also help to put the custom Lua DLL into the same place that MUSHclient has it (ie. the executable folder).
Australia Forum Administrator #15
Fiendish said:

I believe Victorious has installed some other distribution of Lua.exe somewhere else, and that MUSHclient is picking up this other installation's search paths ...


Now that I re-read the question, I think Victorious actually wants MUSHclient to use MUSHclient's Lua DLL (see the thread heading). Thus this is nothing to do with LUA_PATH but everything to do with how Lua.DLL is found in the system search path (once we are looking at LUA_PATH Lua has already started).
USA Global Moderator #16
Ah yeah. I think you're right.