Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Bug reports ➜ Modules not found

Modules not found

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Rollanz   (26 posts)  Bio
Date Fri 29 Nov 2019 10:27 PM (UTC)

Amended on Fri 29 Nov 2019 11:08 PM (UTC) by Rollanz

Message
I fired up MUSHclient for the first time in several months. As soon as I tried to load my world, I got hit by a series of error dialogues in the format of:
Line X: Error parsing script (Cannot load)

Line Y: Error in file <something.xml>


Additionally, the world output showed modules not found messages for "serialize", "json", and "tprint". According to the error message, it looked for e.g. serialize.lua under "L:\lua\lua\include\", which is my LUA_PATH environment variable, but not the default MUSHclient directory at "C:\Program Files (x86)\MUSHclient\lua\"

I was able to partially resolve this problem by adding "C:\Program Files (x86)\MUSHclient\lua\" to LUA_PATH, but surely there's a better way of doing this?


There are still a couple of issues such as this error I run into whenever I try to use the Mushclient mapper version 2.6. I will update with more information if I manage to resolve it.


Run-time error
Plugin: GMCP_Mapper (called from world: Achaea)
Function/Sub: OnPluginBroadcast called by Plugin GMCP_Mapper
Reason: Executing plugin GMCP_Mapper sub OnPluginBroadcast
[string "Plugin: GMCP_Mapper"]:1337: attempt to index global 'json' (a nil value)
stack traceback:
        [string "Plugin: GMCP_Mapper"]:1337: in function <[string "Plugin: GMCP_Mapper"]:1313>


It seems that the json package is throwing up unusual errors.

Edit 1: I've tried both MUSHclient 5.06 and 5.07-pre. I tried reinstallation first and it did not fix the problem.

Edit 2: In GMCP_Mapper.xml, I added

if json then
  print("json found")
else
  print("json missing")
end

to the script section, right under require "json". When I reinstalled the plugin, "json missing" was the output.
I can run require "json" successfully and check that print(json.decode) gives me a function address, so it seems it's just the plugins that can't find the json module?

------------------------
Original error message for the record:

lugin: GMCP_Mapper (called from world: Achaea)
Immediate execution
[string "Plugin: GMCP_Mapper"]:12: module 'serialize' not found:
        no field package.preload['serialize']
        no file 'L:\lua\lua\include\serialize.lua'
        no file '.\serialize.dll'
        no file 'C:\Program Files (x86)\MUSHclient\serialize.dll'
        no file 'C:\Program Files (x86)\MUSHclient\loadall.dll'
stack traceback:
        [C]: in function 'require'
        [string "Plugin: GMCP_Mapper"]:12: in main chunk
[WARNING] L:\Other\MC4\customstuff\GMCP_Mapper.xml
[WARNING] L:\Other\MC4\worlds\munjoie.MCL
Run-time error
Plugin: GMCP (called from world: Achaea)
Immediate execution
L:\Other\MC2\plugins\GMCP.plugin\scripts\main.lua:2: module 'json' not found:
        no field package.preload['json']
        no file 'L:\Other\MC2\plugins\GMCP.plugin\json.lua'
        no file 'L:\Other\MC2\plugins\GMCP.plugin\libraries\json.lua'
        no file 'L:\Other\MC2\plugins\GMCP.plugin\libraries\json\init.lua'
        no file 'L:\Other\MC2\plugins\GMCP.plugin\json.dll'
        no file 'L:\Other\MC2\plugins\GMCP.plugin\libraries\json.dll'
        no file 'C:\Program Files (x86)\MUSHclient\json.dll'
        no file 'C:\Program Files (x86)\MUSHclient\loadall.dll'
stack traceback:
        [C]: in function 'require'
        L:\Other\MC2\plugins\GMCP.plugin\scripts\main.lua:2: in main chunk
        [C]: in function 'require'
        [string "Plugin: GMCP"]:29: in main chunk
[WARNING] L:\Other\MC2\plugins\GMCP.plugin\plugin.xml
[WARNING] L:\Other\MC4\worlds\munjoie.MCL
installing mapwindow plugin
Run-time error
Plugin: GMCP_Unveiler (called from world: Achaea)
Immediate execution
L:\Other\MC2\plugins\GMCP.unveiler\scripts\main.lua:2: module 'tprint' not found:
        no field package.preload['tprint']
        no file 'L:\Other\MC2\plugins\GMCP.unveiler\tprint.lua'
        no file 'L:\Other\MC2\plugins\GMCP.unveiler\libraries\tprint.lua'
        no file 'L:\Other\MC2\plugins\GMCP.unveiler\libraries\tprint\init.lua'
        no file 'L:\Other\MC2\plugins\GMCP.unveiler\tprint.dll'
        no file 'L:\Other\MC2\plugins\GMCP.unveiler\libraries\tprint.dll'
        no file 'C:\Program Files (x86)\MUSHclient\tprint.dll'
        no file 'C:\Program Files (x86)\MUSHclient\loadall.dll'
stack traceback:
        [C]: in function 'require'
        L:\Other\MC2\plugins\GMCP.unveiler\scripts\main.lua:2: in main chunk
        [C]: in function 'require'
        [string "Plugin: GMCP_Unveiler"]:41: in main chunk
[WARNING] L:\Other\MC2\plugins\GMCP.unveiler\plugin.xml
[WARNING] L:\Other\MC4\worlds\munjoie.MCL
GMCP interface unavailable: not_installed
Run-time error
World: Achaea
Immediate execution
[string "Script file"]:2: module 'tprint' not found:
        no field package.preload['tprint']
        no file 'L:\lua\lua\include\tprint.lua'
        no file '.\tprint.dll'
        no file 'C:\Program Files (x86)\MUSHclient\tprint.dll'
        no file 'C:\Program Files (x86)\MUSHclient\loadall.dll'
stack traceback:
        [C]: in function 'require'
        [string "Script file"]:2: in main chunk
Error context in script:
   1 : require "math"
   2*: require "tprint"
   3 : require "serialize"
   4 : 
   5 : --TextRectangle (250, 0, 0, 0, 0, 0x000000, 0, 0x000000, 0)
   6 : 
Top

Posted by Nick Gammon   Australia  (23,163 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 30 Nov 2019 01:36 AM (UTC)

Amended on Sun 01 Dec 2019 05:12 AM (UTC) by Nick Gammon

Message
Why is it looking in L: in the first place? Were you running from a directory on L: at some point?

I suspect that hard-coded references to L: are in the world file, particularly in the list of plugins at the end.

You can edit the world file in a text editor, see if that is what has happened.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rollanz   (26 posts)  Bio
Date Reply #2 on Sat 30 Nov 2019 02:44 AM (UTC)

Amended on Sat 30 Nov 2019 03:03 AM (UTC) by Rollanz

Message
L:\lua\lua is where I keep my Lua 5.3.5 interpreter. The other L:\ directories are the locations of the plugins and world file from old Mushclient install directories and hadn't caused me any problems before.

Let me first mention a result from early in my troubleshooting process. I made a brand new world in the default directory with one alias:


<aliases
   muclient_version="5.06"
   world_file_version="15"
   date_saved="2019-11-29 16:21:02"
  >
  <alias
   match="^test$"
   enabled="y"
   regexp="y"
   send_to="12"
   keep_evaluating="y"
   sequence="100"
  >
  <send>require "tprint"

local t = {"red", "blue", "yellow"}

tprint(t)</send>
  </alias>
</aliases>


The first time I tried to run the alias, I got the error below:


Error number: 0
Event:        Run-time error
Description:  [string "Alias: "]:1: module 'tprint' not found:

	no field package.preload['tprint']

	no file 'L:\lua\lua\include\tprint.lua'

	no file '.\tprint.dll'

	no file 'C:\Program Files (x86)\MUSHclient\tprint.dll'

	no file 'C:\Program Files (x86)\MUSHclient\loadall.dll'

stack traceback:

	[C]: in function 'require'

	[string "Alias: "]:1: in main chunk
Called by:    Immediate execution


I tested three scenarios:
1) No LUA_PATH system environment variable: no error
2) LUA_PATH system environment variable does not include MUSHclient's Lua directory ("L:\lua\lua\include\?.lua"): error
3) LUA_PATH system environment variable includes MUSHclient's Lua directory ("L:\lua\lua\include\?.lua;C:\Program Files (x86)\MUSHclient\lua\?.lua"): no error

I think that's pretty strange behaviour.

Continuing on, I moved my world file, the associated script file, and all the plugins into the respective folders in the C:\ directory where I installed MUSHclient as you suggested. I also made sure there was no remaining reference to L:\ in the world file. The JSON error I mentioned in the previous post still occurred. This happened regardless of whether or not I had the MUSHclient Lua folder in LUA_PATH.

However, the plugin worked as soon as I removed LUA_PATH system environment variable altogether and restarted the client. This isn't an acceptable solution for obvious reasons.

Edit: Reading through luaconf.h in the nickgammon/mushclient repository, am I correct in thinking that LUA_PATH_DEFAULT is only used when LUA_PATH is absent? If so, that could be part of the problem although I still don't see why the require "json" in the plugin would fail regardless of the value of LUA_PATH.
Top

Posted by Nick Gammon   Australia  (23,163 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 01 Dec 2019 05:15 AM (UTC)
Message
MUSHclient comes with a copy of Lua (the DLL that ships with it).

Have you removed that, thus forcing the app to find another copy, which appears to be "my Lua 5.3.5 interpreter"?

If you do that, surely it is not unreasonable for you to tell your own copy of Lua where to find the MUSHclient Lua files? How is it supposed to know otherwise?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rollanz   (26 posts)  Bio
Date Reply #4 on Sun 01 Dec 2019 06:54 AM (UTC)
Message
I have not modified the MUSHclient installation. I have just verified that lua5.1.dll is still in the MUSHclient directory. If I had removed MUSHclient's Lua interpreter, it wouldn't have worked correctly when LUA_PATH was removed completely?

I also uninstalled and re-installed MUSHclient to make sure file corruption wasn't the cause.


Here are the minimum reproduction steps:
1) Install a fresh copy of MUSHclient
2) Create a new world
3) Create an alias that requires tprint and then tprints a table. Run it.

Everything should work so far.

4) Close MUSHclient
5) Add LUA_PATH variable to system environment (System Properties -> Advanced -> Environment Variables -> New (System variables) -> type in "LUA_PATH" for variable name and an arbitrary directory + "\?.lua" for variable value)
6) Open MUSHclient and run the alias again

The last step should result in an error.
Top

Posted by Fiendish   USA  (2,541 posts)  Bio   Global Moderator
Date Reply #5 on Mon 02 Dec 2019 02:49 PM (UTC)

Amended on Mon 02 Dec 2019 03:03 PM (UTC) by Fiendish

Message
This is a standard behavior of Lua.

On https://www.lua.org/manual/5.1/manual.html#pdf-package.path (under package.path) it says:

Quote:
At start-up, Lua initializes this variable with the value of the environment variable LUA_PATH or with a default path defined in luaconf.h, if the environment variable is not defined. Any ";;" in the value of the environment variable is replaced by the default path.


On https://www.lua.org/pil/8.1.html it says:

Quote:
To determine its path, require first checks the global variable LUA_PATH. If the value of LUA_PATH is a string, that string is the path. Otherwise, require checks the environment variable LUA_PATH. Finally, if both checks fail, require uses a fixed path (typically "?;?.lua", although it is easy to change that when you compile Lua).



Note that those two statements do not describe exactly the same behavior. I don't know which one is accurate.

Rollanz, it seems like you could add `;;` to your LUA_PATH system variable.

Nick, I think the PIL description means that you could set a LUA_PATH global variable in MUSHclient to keep require lookups local to the MUSHclient folder like they should be?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Rollanz   (26 posts)  Bio
Date Reply #6 on Tue 03 Dec 2019 03:45 AM (UTC)
Message
Thanks for the information, Fiendish.

The latter (changing my LUA_PATH to "?;?.lua;L:\lua\lua\include\?.lua") made the same errors pop up as the original report.

The former (changing my LUA_PATH to "L:\lua\lua\include\?.lua;;") had the same effect as adding the Mushclient Lua folder to the LUA_PATH. That is, the world loaded fine but then the plugins couldn't find the JSON module. It probably bears repeating that the JSON module issue doesn't occur if I remove LUA_PATH.

I'll try to figure out minimal steps to replicate the latter issue when I have time.
Top

Posted by Nick Gammon   Australia  (23,163 posts)  Bio   Forum Administrator
Date Reply #7 on Tue 03 Dec 2019 05:55 AM (UTC)

Amended on Tue 03 Dec 2019 07:07 AM (UTC) by Nick Gammon

Message
I don't think this is a bug. As Fiendish pointed out, the default behaviour is to initialize package.path and package.cpath (for DLLs) with the current path at the time of execution.

In my case, with no LUA_PATH environment variable declared in Windows, this is where it looks:

package.path


.\?.lua;C:\Program Files\MUSHclient\lua\?.lua;C:\Program Files\MUSHclient\lua\?\init.lua;C:\Program Files\MUSHclient\?.lua;C:\Program Files\MUSHclient\?\init.lua


package.cpath



.\?.dll;C:\Program Files\MUSHclient\?.dll;C:\Program Files\MUSHclient\loadall.dll



To reproduce:


print (package.path)
print (package.cpath)





Now once you replace that with an explicit path, then of course it doesn't find the module in the MUSHclient directory because it is not looking there.

As a workaround that doesn't involve changing the LUA_PATH environment variable, I went to the File menu -> Global Preferences -> Lua and added the following two lines:


package.path = package.path .. ';.\\?.lua;' .. GetInfo (56) .. 'lua\\?.lua'

package.cpath = package.cpath .. ';.\\?.dll;' .. GetInfo (56) .. 'lua\\?.dll'


Now that will take your current package.path (and package.cpath) and append the location of the current directory, and also the Lua directory under the MUSHclient executable.

I tested this on Aardwolf, which uses json amongst other things.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rollanz   (26 posts)  Bio
Date Reply #8 on Wed 04 Dec 2019 03:49 AM (UTC)
Message
Thanks for the work-around!

I'm embarrassed to say that the json issue was entirely caused by me having a json.lua file I was messing around with in my default directory.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


23,651 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.