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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Henkoglobin
Prole
Posts: 3
Joined: Fri Jan 31, 2014 11:53 am

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

Post 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
Attachments
test.love
A test file that works for me (Win8.1, x64) but not for (Win7, x64).
(641 Bytes) Downloaded 93 times
Last edited by Henkoglobin on Mon Feb 10, 2014 7:59 pm, edited 1 time in total.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Strange behaviour of require on different Windows platfo

Post 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.
Help us help you: attach a .love.
Henkoglobin
Prole
Posts: 3
Joined: Fri Jan 31, 2014 11:53 am

Re: Strange behaviour of require on different Windows platfo

Post 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.
Attachments
testwithlog.love
(727 Bytes) Downloaded 88 times
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Strange behaviour of require on different Windows platfo

Post by Robin »

It's a long shot, but maybe if you requiring "lib.loadme" instead of "lib/loadme". (The former's more official syntax.)
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Strange behaviour of require on different Windows platfo

Post by bartbes »

You'll need to require love.filesystem before you'll be able to.. well, access love's filesystem.
Henkoglobin
Prole
Posts: 3
Joined: Fri Jan 31, 2014 11:53 am

Re: Strange behaviour of require on different Windows platfo

Post 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?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

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

Post by bartbes »

Because it works with the lua loader if your files are in the working directory when running the game.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 5 guests