Page 1 of 1

[Solved] Strange behaviour of require on different Windows..

Posted: Fri Jan 31, 2014 12:10 pm
by Henkoglobin
Hey everybody,

Today, I had a very strange problem: A love file that is working without a single problem on my PC (Windows 8.1 64 bit) fails to require a file on another PC (Windows 7 64 bit). Especially, the required file is in a sub-directory and is required from a thread.

It seems that the thread might cause the problem, because some quick tests indicate that files are loaded perfectly from within a subdirectory if require is not called from within a thread. The love file I have attached demonstrates this (somewhat): If run on my PC, it outputs "I was loaded" to the attached console. However, it doesn't output anything (not even an error, which is even more strange) on the other guy's PC.

I will try to replicate the exact error (failing to require a file) in an MWE (http://meta.tex.stackexchange.com/quest ... at-is-that) so that I don't have to include the whole source code. But basically, it really just starts a thread which, in turn, requires the file from the subdirectory.

So, the basic question is: Are there any known issues concerning the loading of lua files from a subdirectory, possibly in relation to using threads?

Cheers,
Henrik

Re: Strange behaviour of require on different Windows platfo

Posted: Fri Jan 31, 2014 12:18 pm
by Robin
Errors raised in threads don't propagate, so if you want to discover when an error has occurred in a thread, define a love.[wiki]threaderror[/wiki] callback in the main thread.

Re: Strange behaviour of require on different Windows platfo

Posted: Fri Jan 31, 2014 12:37 pm
by Henkoglobin
Alright, totally forgot about that, ha :D

I added error logging and attached the updated love file to this posting. The resulting error log is as follows:

Code: Select all

stuff.lua:1: module 'lib/loadme' not found:
	no field package.preload['lib/loadme']
	no file '.\lib/loadme.lua'
	no file 'G:\LOVE\lua\lib/loadme.lua'
	no file 'G:\LOVE\lua\lib/loadme\init.lua'
	no file '.\lib/loadme.dll'
	no file 'G:\LOVE\lib/loadme.dll'
	no file 'G:\LOVE\loadall.dll'
As before, it works perfectly fine on my machine, but not on the other guy's.

Re: Strange behaviour of require on different Windows platfo

Posted: Fri Jan 31, 2014 12:40 pm
by Robin
It's a long shot, but maybe if you requiring "lib.loadme" instead of "lib/loadme". (The former's more official syntax.)

Re: Strange behaviour of require on different Windows platfo

Posted: Fri Jan 31, 2014 1:00 pm
by bartbes
You'll need to require love.filesystem before you'll be able to.. well, access love's filesystem.

Re: Strange behaviour of require on different Windows platfo

Posted: Mon Feb 10, 2014 7:58 pm
by Henkoglobin
Hey, sorry for letting you all wait for so long.

bartbes' tip is absolutely correct and it now works on the other person's computer as well. I am still puzzled why it worked on my machine, though. Is there any explanation for this?

Re: [Solved] Strange behaviour of require on different Windo

Posted: Wed Feb 12, 2014 3:15 pm
by bartbes
Because it works with the lua loader if your files are in the working directory when running the game.