Discussion:
PAR vs MIME::Types
(too old to reply)
Philip Gwyn
2015-06-11 18:09:39 UTC
Permalink
Hello,

MIME::Types uses __FILE__ to locate it's data file (types.db). This fails from
inside a PAR file, because of the #file 1 "MIME/Types.pm" that PAR adds.

I've filed a bug about this
https://rt.cpan.org/Ticket/Display.html?id=104945

The author's reply is that this is a bug in PAR, not MIME::Types.

To me, all libraries should allow the caller to specify where to find data
files.

In fact File::ShareDir is a much better option then __FILE__ or %INC.

Anyone willing to weigh in on the argument?

-Philip
Roderich Schupp
2015-06-14 12:32:04 UTC
Permalink
Post by Philip Gwyn
To me, all libraries should allow the caller to specify where to find data
files.
That's a nightmare for admins and packagers...
Post by Philip Gwyn
In fact File::ShareDir is a much better option then __FILE__ or %INC.
What I would like to see (as in "could I haz a pony?") is a standard
way for tools
like PAR to inspect or intercept loading of data. And then have a every module
converted to use that. But that won't happen, TIMTOWTDI rules.

BTW, it's fine with me if people submit bugs against PAR::Packer for
cases like this.
It generally takes one line in Module::ScanDeps and perhaps another two in
PAR::Packer to fix this.
Post by Philip Gwyn
Anyone willing to weigh in on the argument?
Anyway, for MIME::Types this will be solved in the next release of PAR::Packer:
it will patch the packaged MIME::Types to load types.db from its
packaged location.


Cheers, Roderich
Ron W
2015-06-15 17:31:11 UTC
Permalink
Post by Roderich Schupp
Post by Philip Gwyn
To me, all libraries should allow the caller to specify where to find
data
Post by Philip Gwyn
files.
That's a nightmare for admins and packagers...
Looking at MIME::Types, I see the following in _read_db

my $db = $ENV{PERL_MIME_TYPE_DB}
|| $args->{db_file}
|| File::Spec->catfile(dirname(__FILE__), 'types.db');

So, MIME::Types already provides a way for the caller to specify where to
find data.

If there is a standard location in the package, relative to the packaged
application, for data files, then I would say there's no need to make a
change to PAR::Packer

If I were going to make a change to PAR::Packer, I would be inclined to
provide the packaged application with $ENV{PP_PERL_MIME_TYPE_DB} set to the
packaged location of types.db so that the application could then decide
where to tell the module to look for the file.
Roderich Schupp
2015-06-16 06:24:08 UTC
Permalink
Post by Ron W
If I were going to make a change to PAR::Packer, I would be inclined to
provide the packaged application with $ENV{PP_PERL_MIME_TYPE_DB} set to the
packaged location of types.db so that the application could then decide
where to tell the module to look for the file.
Sorry, that approach isn't possible with the current infrastructure in
PAR::Packer (whereas patching
works now by adding two lines of code to the PatchContent filter). But
basically bothhave the same flaw:
they depend on knowledge about the inner workings of MIME::Types.

Cheers, Roderich

Loading...