Skip Menu |

This queue is for tickets about the PAR CPAN distribution.

Report information
The Basics
Id: 26614
Status: open
Priority: 0/
Queue: PAR

People
Owner: Nobody in particular
Requestors: fagga [...] gmx.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Problem with __FILE__
Date: Tue, 24 Apr 2007 21:51:44 +0200
To: bug-PAR [...] rt.cpan.org
From: fagga <fagga [...] gmx.de>
Hello, I'm using the Curses::UI module and want to package it with my application in a PAR executable. Curses::UI makes use of the special literal __FILE__ which, without being in a PAR package, resolves into the full path of the module file name "/usr/share/perl5/Curses/UI/Language.pm". But inside a PAR package it resolves to "Curses/UI/Language.pm" and I get a "file not found" error. Because __FILE__ changes it's behaviour depending on being in PAR or not, I think this is a bug in PAR. I'm using the Debian version of PAR (0.952), but I also tried the version from CPAN (0.973) and it was all the same. Thank you very much for reading this and for this nevertheless great module. I was very happy when I found it. (: Greetings, Benjamin
Hallo Benjamin, On Tue Apr 24 15:52:09 2007, fagga@gmx.de wrote: Show quoted text
> I'm using the Curses::UI module and want to package it with my > application in a PAR executable. Curses::UI makes use of the special > literal __FILE__ which, without being in a PAR package, resolves into > the full path of the module file name > "/usr/share/perl5/Curses/UI/Language.pm". But inside a PAR package it > resolves to "Curses/UI/Language.pm" and I get a "file not found" > error. Because __FILE__ changes it's behaviour depending on being in > PAR or not, I think this is a bug in PAR.
You're probably right, this could be considered a bug in PAR. At the same time, however, I feel this is a bug in Curses::UI::Language. But first things first: As you may have guessed PAR does some heavy shuffling of files, file names, and code to do its magic. The .par's or .exe's contents are extracted to a temporary directory before being loaded. What exactly is extracted and how and where it goes is determined by a myriad of factors. Admitted, it should set __FILE__ right when loading a module. But OTOH, it does *not* explicitly set __FILE__ wrong, so it is probably a pretty hard-to-find bug which is most likely intimately related to how a specific .pm file was loaded. My PAR maintenance time is severely limited these days, so I can't take the time to search this. I did, however, have a quick look at how Curses::UI uses the __FILE__ token because it seemed strange to me that a module would want to know where it's physically (well, almost) located in the file system. It turns out that Curses::UI::Language::loadlanguage() uses __FILE__ to determine the location and file name of Curses::UI::Language::foo (i.e. Curses/UI/Language/foo.pm) modules. That's certainly a bug since nobody guarantees that various Curses::UI::Language::* modules are installed into the same module search path. (On a side-note: As you're on debian, you probably noticed debian has something like a hundred thousand paths it likes to scatter its modules into.) Now, there is a way to go about this which makes use of Perl's built-in module (file) searching algorithm instead of doing all the file searching by hand as Curses::UI does. That method should not be broken by PAR mangling __FILE__: - Instead of working with file names, the loadlanguage() sub would work with namespaces. It would append ::langname to its own namespace (__PACKAGE__). - Then, it would eval("require $thatnamespace;") to make sure its loaded. - Next, it would fetch the DATA file handle which is opened by perl for it. That skips the opening of the module source code file by hand. Admittedly, this approach also has some perils, but at least they're hacks that stay within the Perl code and do not depend on file system interaction. I implemented the algorithm outlined above with PAR::StrippedPARL::Base, ::Static, and ::Dynamic. ::Base has all the heavy lifting and the other classes inherit from it. PAR::StrippedPARL::Base would become Curses::UI::Language::Base or so. Curses::UI::Language would load the corresponding language class (which inherits from ::Base) and call something like ->fetch_data_handle() or so on it. Of course, you could make Curses::UI::Language the base class itself. I don't know whether the Curses::UI maintainer would accept a patch to do this, of course. I'll keep this ticket open because even if Curses::UI::Language was modified, the PAR bug would stay. Show quoted text
> Thank you very much for reading this and for this nevertheless great > module. I was very happy when I found it. (:
Thanks for the praise! Steffen
Subject: Re: [rt.cpan.org #26614] Problem with __FILE__
Date: Thu, 26 Apr 2007 21:59:59 +0200
To: Steffen Müller via RT <bug-PAR [...] rt.cpan.org>
From: fagga <fagga [...] gmx.de>
<URL: http://rt.cpan.org/Ticket/Display.html?id=26614 > Hello Steffen, thank you very much, again. I would have never come to this solution without your help. With your detailed explanations it took me just a few minutes to get a working PAR package. Show quoted text
> I don't know whether the Curses::UI maintainer would accept a patch to > do this, of course.
I'll send him the changes I made, even as the whole project seems to be unmaintained. Happily, Benjamin
Hi Benjamin, On Thu Apr 26 16:00:17 2007, fagga@gmx.de wrote: Show quoted text
> I'll send him the changes I made, even as the whole project seems to > be unmaintained.
in case the author has no further interest in maintaining the module, he can transfer maintenance to you via PAUSE. If he is entirely* unreachable, you can write to modules at perl dot org and we can see about making you co-maintainer. Of course, this is a measure of last resort and there's nothing we can do if the author is responsive but rejects the patch. Cheers, Steffen * "Entirely" means that one would have to try to contact the maintainer by all means possible (email, RT, google, and what not) and wait for an extended period of time. Also, it's necessary to show to modules@ that this effort was made. But lets hope for the best.
Subject: Re: [rt.cpan.org #26614] Problem with __FILE__
Date: Fri, 27 Apr 2007 12:40:42 +0200
To: Steffen Müller via RT <bug-PAR [...] rt.cpan.org>
From: fagga <fagga [...] gmx.de>
Hello Steffen, Show quoted text
> in case the author has no further interest in maintaining the module, he > can transfer maintenance to you via PAUSE. If he is entirely* > unreachable, you can write to modules at perl dot org and we can see > about making you co-maintainer.
I don't know if I'm skilled enough to do this. I never maintained such a project. And I just found another problem with Curses::UI being inside PAR without having any idea how to debug it. But maybe I would still be better than no maintainer at all. Benjamin
From: SMUELLER [...] cpan.org
Hi Benjamin, On Fri Apr 27 06:44:32 2007, fagga@gmx.de wrote: Show quoted text
> I don't know if I'm skilled enough to do this. I never maintained > such a project. And I just found another problem with Curses::UI being > inside PAR without having any idea how to debug it. But maybe I would > still be better than no maintainer at all.
I had an email exchange with the Curses::UI maintainer. He said he could no longer maintain it, but he passed it on to Shawn Boyette (CPAN ID "MDXI") who will start maintaining it. I suspect he will apply the patch you posted to the RT queue of the module. So finally, your problems should eventually be solved. Best regards, Steffen
Subject: Re: [rt.cpan.org #26614] Problem with __FILE__
Date: Sun, 24 Jun 2007 18:43:52 +0200
To: Steffen Müller via RT <bug-PAR [...] rt.cpan.org>
From: fagga <fagga [...] gmx.de>
Hi Steffen, Show quoted text
> On Fri Apr 27 06:44:32 2007, fagga@gmx.de wrote:
> > I don't know if I'm skilled enough to do this. I never maintained > > such a project. And I just found another problem with Curses::UI being > > inside PAR without having any idea how to debug it. But maybe I would > > still be better than no maintainer at all.
> > I had an email exchange with the Curses::UI maintainer. He said he could > no longer maintain it, but he passed it on to Shawn Boyette (CPAN ID > "MDXI") who will start maintaining it. I suspect he will apply the patch > you posted to the RT queue of the module. So finally, your problems > should eventually be solved.
Wow, that's quite a service. Thank you very much for your commitment. In the meantime, I wrote my own implementation as Curses::UI was too bloated for my purpose anyway. Nevertheless it's good to hear that this Module isn't dead anymore. Greetings, Benjamin