Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

NEW SIMPLE EXAMPLE

I'm updating this node with a very simple test case that demonstrates the problem and does not require Mojolicious:
# works in plain perl # fails with this compilation line: # pp -P -r -v 99 -o packed.pl somefile.pl BEGIN { use File::Spec; for (@INC) { if ( !ref $_ && -d $_ && !File::Spec->file_name_is_absolute($_ +) ) { $_ = File::Spec->rel2abs($_); } } } sub hello { my $file = __FILE__; warn "My file name is $file. Here is my contents:"; open(my $fh, "<", $file); my @data = <$fh>; warn "@data"; } hello(); 1;

OLD NODE

With the latest Mojolicious from CPAN, if you use PAR::Packer to create an executable for webapp.pl by running pack.pl (by cloning this repo) then Mojolicious::Controller will fail to find the template directory because it uses this code to do so:
my $T = File::Spec->catdir(File::Basename::dirname(__FILE__), 'templat +es');
Because PAR::Packer-based executables run out of a temp directory, the relative path returned by __FILE__ is not found. Changing line 21 to
my $T = File::Spec->catdir(File::Basename::dirname($INC{'Mojolicious/L +ite.pm'} || __FILE__), 'templates');
results in the binary version of webapp.pl running successfully.

good questions, no answer yet

The author of Mojolicious asked a good question regarding my described symptoms:
18:18 <@sri> even if it's in a temporary directory why would __FILE__ return the wrong file?

related nodes

this person did not run into this problem for some reason

In reply to __FILE__ fails in app built with PAR::Packer by metaperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-18 03:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found