Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Building a Mojolicious app with PAR::Packer

by Hue-Bond (Priest)
on Feb 25, 2011 at 08:27 UTC ( [id://890146]=perlquestion: print w/replies, xml ) Need Help??

Hue-Bond has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed monks,

I'm trying to make an .exe file out of a little program using Mojolicious::Lite. It's Strawberry Perl 5.12.0 on Windows XP SP2 (perl built for MSWin32-x86-multi-thread).

The code couldn't be simpler:

#!/usr/bin/perl use Mojolicious::Lite;

This is what happens when I try to build it:

> pp -o use-mojo.exe use-mojo.pl > use-mojo.exe Can't locate Mojolicious.pm in @INC (@INC contains: CODE(0x13ddff4) C: +\DOCUME~1\hue\CONFIG~1\Temp\par-hue\cache-b63530375d9cac583a4739b81f2 +5c342b562e895\inc\lib C:\DOCUME~1\hue\CONFIG~1\Temp\par-hue\cache-b63 +530375d9cac583a4739b81f25c342b562e895\inc CODE(0x121b2fc) CODE(0x121b +5fc)) at Mojo/Base.pm line 31. BEGIN failed--compilation aborted at Mojolicious/Lite.pm line 2. Compilation failed in require at script/use-mojo.pl line 3. BEGIN failed--compilation aborted at script/use-mojo.pl line 3.

Hmm well, ok, let's manually include the missing module:

> pp -M Mojolicious -o use-mojo.exe use-mojo.pl > use-mojo.exe Can't locate Mojo.pm in @INC (@INC contains: CODE(0x1360614) C:\DOCUME +~1\hue\CONFIG~1\Temp\par-hue\cache-32243079ff9cdbe34fb6720d972d912551 +5e65d7\inc\lib C:\DOCUME~1\hue\CONFIG~1\Temp\par-hue\cache-32243079ff +9cdbe34fb6720d972d9125515e65d7\inc CODE(0x121b2fc) CODE(0x121b5fc)) a +t Mojo/Base.pm line 31. BEGIN failed--compilation aborted at Mojolicious.pm line 2. Compilation failed in require at Mojo/Base.pm line 31. BEGIN failed--compilation aborted at Mojolicious/Lite.pm line 2. Compilation failed in require at script/use-mojo.pl line 3. BEGIN failed--compilation aborted at script/use-mojo.pl line 3.

Ok, maybe it's another kind of problem. Let's try with -I:

> perl -MMojolicious -MMojo -le "print $INC{'Mojolicious.pm'}; print $ +INC{'Mojo.pm'}" C:/strawberry/perl/site/lib/Mojolicious.pm C:/strawberry/perl/site/lib/Mojo.pm > pp -I C:/strawberry/perl/site/lib -o use-mojo.exe use-mojo.pl > use-mojo.exe Can't locate Mojolicious.pm in @INC (@INC contains: CODE(0x13ddff4) C: +\DOCUME~1\hue\CONFIG~1\Temp\par-hue\cache-362b7854cb57139506964b066a4 +ae6568fad1611\inc\lib C:\DOCUME~1\hue\CONFIG~1\Temp\par-hue\cache-362 +b7854cb57139506964b066a4ae6568fad1611\inc CODE(0x121b2fc) CODE(0x121b +5fc)) at Mojo/Base.pm line 31. BEGIN failed--compilation aborted at Mojolicious/Lite.pm line 2. Compilation failed in require at script/use-mojo.pl line 3. BEGIN failed--compilation aborted at script/use-mojo.pl line 3.

Uh, I'm back to square 1. Same result if I try with backslashes.

Well, at this point I made a .bat file with a bunch of modules and tried with it. This is the batch:

pp ^ -I . ^ -I C:\strawberry\perl\site\lib ^ -I C:\strawberry\perl\site ^ -M Mojolicious ^ -M Mojo ^ -M Mojo::Asset ^ -M Mojo::Base ^ -M Mojo::ByteStream ^ -M Mojo::Cache ^ -M Mojo::Client ^ -M Mojo::Command ^ -M Mojo::Content ^ -M Mojo::Cookie ^ -M Mojo::CookieJar ^ -M Mojo::Date ^ -M Mojo::DOM ^ -M Mojo::Exception ^ -M Mojo::Headers ^ -M Mojo::HelloWorld ^ -M Mojo::Home ^ -M Mojo::IOLoop ^ -M Mojo::JSON ^ -M Mojo::Loader ^ -M Mojo::Log ^ -M Mojo::Message ^ -M Mojo::Parameters ^ -M Mojo::Path ^ -M Mojo::Server ^ -M Mojo::Template ^ -M Mojo::Transaction ^ -M Mojo::Upload ^ -M Mojo::URL ^ -M Mojo::Util ^ -o use-mojo.exe use-mojo.pl

And the output:

> use-mojo.exe script: No such file or directory at Mojo/Home.pm line 25 BEGIN failed--compilation aborted at script/use-mojo.pl line 3.

It seems I've advanced a little, but I guess there's a better (less explicit/verbose) way to build the .exe and I shouldn't be using this batch file.

I've googled around (with and without site:perlmonks.org) to no avail. I guess I must be missing some bit along the way but can't figure out which one it is. Any idea? Thanks!

--
 David Serrano
 (Please treat my english text just like Perl code, i.e. feel free to notify me of any syntax, grammar, style and/or spelling errors. Thank you!).

Replies are listed 'Best First'.
Re: Building a Mojolicious app with PAR::Packer
by Anonymous Monk on Feb 25, 2011 at 11:31 UTC
    pp comes with options Now regarding error script: No such file or directory at Mojo/Home.pm line 25 This is line 25 of Mojo/Home.pm
    # Environment variable if ($ENV{MOJO_HOME}) { my @parts = File::Spec->splitdir(abs_path $ENV{MOJO_HOME}); $self->{_parts} = \@parts; return $self; }
    So there is line number confusion.

    Using

    require Mojolicious::Lite;
    seems to remedy this situation. Oddly BEGIN { eval "use Mojolicious::Lite;" } also works.

    Thats bizzare, you should submit a bug report :)

      All of -n -x, -x and -c do the trick and take me to the Mojo/Home.pm line 25 error. I hadn't noticed that the error was precisely in that file: as soon as you pointed it out I remembered that the test t/mojo/home.t had failed before the (forced) installation. Thankfully, Google has something to say about it so I'll now concentrate on that.

      Thank you!

      --
       David Serrano
       (Please treat my english text just like Perl code, i.e. feel free to notify me of any syntax, grammar, style and/or spelling errors. Thank you!).

        No line number confusion: abs_path was dying. Turns out that the failing test had nothing to do with it - the problem is caused due to an interference with PAR's runtime environment. Prepending a bit of code to the main script works around the problem:

        use File::Spec; BEGIN { if ($ENV{'PAR_TEMP'}) { my $dir = File::Spec->catfile ($ENV{'PAR_TEMP'}, 'inc'); chdir $dir or die "chdir: '$dir': $!"; } }

        We go to the parent directory of script so now it's properly detected.

        --
         David Serrano
         (Please treat my english text just like Perl code, i.e. feel free to notify me of any syntax, grammar, style and/or spelling errors. Thank you!).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://890146]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-23 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found