Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Again with PAR::Packer troubles

by jellisii2 (Hermit)
on Aug 16, 2011 at 15:38 UTC ( [id://920506]=perlquestion: print w/replies, xml ) Need Help??

jellisii2 has asked for the wisdom of the Perl Monks concerning the following question:

I can't seem to catch a break this week.

use strict; use warnings; use LWP::Debug qw(+); use WWW::Mechanize; use HTML::HeadParser; use Crypt::SSLeay; # added per suggestion by zentara require HTML::HeadParser; my $mech = WWW::Mechanize->new(cookie_jar => {}, autocheck => 0); $mech->agent_alias( 'Windows Mozilla' ); $mech->get('https://www.google.com'); print "\n", $mech->uri(); print "\n", $mech->status(); print "\n", $mech->text(); print "\n" . $mech->success(); while (my ($key, $value) = each(%INC)) { print "$key\n"; }

The above works from the command line.

Using pp -x, the command works as expected.

Running a.exe nets the following:

Can't connect to www.google.com:443

command line for pp:

pp -x mech_test.pl

Dumping %INC doesn't make any revelations of packages that I or Par have missed, with the exception of HTML::HeadParser. I *suspect* there's something that I need to pass to pp as a module that scandeps isn't picking up on, but I'm at a loss to discover what it is.

Relevant information about my environment can be found at The locale codeset (cp1252) isn't one that perl can decode

Thanks in advance.

Further troubleshooting indicates that the problem may be with LWP or below it.

use strict; use warnings; use LWP::UserAgent; use LWP::Debug qw(+); use HTML::HeadParser; use Crypt::SSLeay; use Data::Dumper; my $ua = LWP::UserAgent->new; $ua->agent("LWP"); my $request = HTTP::Request->new(GET => "https://www.google.com"); my $result = $ua->request($request); print Dumper($result);

From command line, the dumper output is this:

$VAR1 = bless( { '_protocol' => 'HTTP/1.1', '_content' => '<!doctype html><html><head><meta http- +equiv="con tent-type" content="text/html; charset=ISO-8859-1"><meta name="descrip +tion" cont ent="Search the world&#39;s information, including webpages, images, v +ideos and more. Google has many special features to help you find exactly what y +ou&#39;re looking for."><meta name="robots" content="noodp"><title>Google</title +><script>w indow.google={kEI:"hbZKTr6EDtO3tweM5eChCg",getEI:function(a){var c;whi +le(a&&!(a. getAttribute&&(c=a.getAttribute("eid"))))a=a.parentNode;return c||goog +le.kEI},kE XPI:"28936,29816,30542,31935,32034,32083",kCSI:{e:"28936,29816,30542,3 +1935,32034 ,32083",ei:"hbZKTr6EDtO3tweM5eChCg",expi:"28936,29816,30542,31935,3203 +4,32083"}, authuser:0,ml:function(){},kHL:"en",time:function(){return(new Date).g +etTime()}, log:function(a,c,d){var b=new Image,e=google,g=e.lc,f=e.li;b.onerror=( +b.onload=( b.onabort=function(){delete g[f]}));g[f]=b;d=d||"/gen_204?atyp=i&ct="+ +a+"&cad="+ c+"&zx="+google.time();b.src=d;e.li=f+1},lc:[],li:0,Toolbelt:{}}; window.google.sn="webhp";var i=window.google.timers={};window.google.s +tartTick=f unction(a,b){i[a]={t:{start:(new Date).getTime()},bfr:!(!b)}};window.g +oogle.tick =function(a,b,c){if(!i[a])google.startTick(a);i[a].t[b]=c||(new Date). +getTime()} ;google.startTick("load",true);try{}catch(v){} var _gjwl=location;function _gjuc(){var e=_gjwl.href.indexOf("#");if(e +>=0){var a =_gjwl.href.substring(e);if(a.indexOf("&q=")>0||a.indexOf("#q=")>=0){a +=a.substri ng(1);if(a.indexOf("#")==-1){for(var c=0;c<a.length;){var d=c;if(a.cha +rAt(d)=="& ")++d;var b=a.indexOf("&",d);if(b==-1)b=a.length;var f=a.substring(d,b +);if(f.ind exOf("fp=")==0){a=a.substring(0,c)+a.substring(b,a.length);b=c}else if +(f=="cad=h ")return 0;c=b}_gjwl.href="/search?"+a+"&cad=h";return 1}}}return 0}fu +nction _gj p(){!(window._gjwl.hash&& window._gjuc())&&setTimeout(_gjp,500)}; window._gjp && _gjp()</script><style id=gstyle>body{margin:0;overflow- +y:scroll}# gog{padding:3px 8px 0}td{line-height:.8em}.gac_m td{line-height:17px}f +orm{margin -bottom:20px}body,td,a,p,.h{font-family:arial,sans-serif}.h{color:#36c +;font-size :20px}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}em{f +ont-weight :bold;font-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:1 +8px arial, sans-serif}.gsfs{font:17px arial,sans-serif}.ds{border-bottom:solid 1p +x #e7e7e7; border-right:solid 1px #e7e7e7;display:-moz-inline-box;display:inline- +block;marg in:3px 0 4px;margin-left:4px}input{font-family:inherit}a.gb1,a.gb2,a.g +b3,a.gb4{c olor:#11c !important}#gbar,#guser{font-size:13px;padding-top:1px !impo +rtant}#gba r{height:22px}#guser{padding-bottom:7px !important;text-align:right}.g +bh,.gbd{bo rder-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolu +te;top:24p x;width:100%}@media all{.gb1{height:22px;margin-right:.5em;vertical-al +ign:top}#g bar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1 +,a.gb4{col or:#00c !important}body{background:#fff;color:black}input{-moz-box-siz +ing:conten t-box}a{color:#11c;text-decoration:none}a:hover,a:active{text-decorati +on:underli ne}.fl a{color:#36c}a:visited{color:#551a8b}a.gb1,a.gb4{text-decoratio +n:underlin e}a.gb3:hover{text-decoration:none}#ghead a.gb2:hover{color:#fff!impor +tant}.sblc {padding-top:5px}.sblc a{display:block;margin:2px 0;margin-left:13px;f +ont-size:1 1px;}.lsbb{background:#eee;border:solid 1px;border-color:#ccc #999 #99 +9 #ccc;hei ght:30px;display:block}.ftl,#fll a{display:inline-block;margin:0 12px} +.lsb{backg round:url(/images/srpr/nav_logo80.png) bottom;border:none;color:#000;c +ursor:poin ter;height:30px;margin:0;outline:0;font:15px arial,sans-serif;vertical +-align:top }.lsb:active{background:#ccc}.lst:focus{outline:none}#addlang a{paddin +g:0 3px}.g ac_v div{display:none}.gac_v .gac_v2,.gac_bt{display:block!important}< +/style><sc ript>google.y={};google.x=function(e,g){google.y[e.id]=[e,g];return fa +lse};</scr ipt></head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a +8b alink=# ff0000 onload="document.f&&document.f.q.focus();document.gbqf&&documen +t.gbqf.q.f ocus();if(document.images)new Image().src=\'/images/srpr/nav_logo80.pn +g\'" ><tex tarea id=csi style=display:none></textarea><div id=mngb><div id=guser +width=100% ><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><sp +an id=gbe> <a href="/url?sa=p&pref=ig&pval=3&q=http://www.google.com/ig%3Fhl%3Den +%26source% 3Diglk&usg=AFQjCNFA18XPfgb7dKnXfKz7x7g1GDH1tg" class=gb4>iGoogle</a> | + </span><a href="/preferences?hl=en" class=gb4>Settings</a> | <a href="https://w +ww.google. com/accounts/ServiceLogin?hl=en&continue=https://encrypted.google.com/ +" class=gb 4>Sign in</a></nobr></div><div class=gbh style=left:0></div><div class +=gbh style =right:0></div></div><iframe name=wgjf style=display:none></iframe><ce +nter><br c lear=all id=lgpd><div id=lga><img src="images/logos/ssl_logo_lg.gif"bo +rder=0 hei ght=110 onload="window.lol&&lol()" width=276><br></div><span id=ssleh +style="fon t-size:smaller">Go to <a href="http://www.google.com/">classic Google< +/a>.</span ><form action="/search" name=f><table cellpadding=0 cellspacing=0><tr +valign=top ><td width=25%>&nbsp;</td><td align=center nowrap><input name=hl type= +hidden val ue=en><input name=source type=hidden value=hp><input type=hidden name= +ie value=" ISO-8859-1"><div class=ds style="height:32px;margin:4px 0"><input auto +complete=o ff maxlength=2048 name=q class="lst" title="Google Search" value="" si +ze=57 styl e="background:#fff;border:1px solid #ccc;border-bottom-color:#999;bord +er-right-c olor:#999;color:#000;margin:0;padding:5px 8px 0 6px;vertical-align:top +"></div><b r style="line-height:0"><span class=ds ><span class=lsbb><input name=b +tnG type=s ubmit value="Google Search" class=lsb></span></span><span class=ds><sp +an class=l sbb><input name=btnI type=submit class=lsb value="I&#39;m Feeling Luck +y"></span> </span></td><td nowrap width=25% align=left class="fl sblc"><a href="/ +advanced_s earch?hl=en">Advanced search</a><a href="/language_tools?hl=en">Langua +ge tools</ a></td></tr></table></form><div style="font-size:83%;min-height:3.5em" +><br></div ><div id=res></div><span id=footer><center id=fctr><span style="font-s +ize:smalle r"><a href="http://www.google.com/support/websearch/bin/answer.py?answ +er=173733& amp;hl=en">Learn more</a> about searching on Google with SSL.</span><b +r><br><div style="font-size:10pt"><div id=fll style="margin:19px auto;text-align +:center">< a href="/intl/en/ads/">Advertising&nbsp;Programs</a><a href="/services +/">Busines s Solutions</a><a href="/intl/en/about.html">About Google</a></div></d +iv><p styl e="color:#767676;font-size:8pt">&copy; 2011 - <a href="/intl/en/privac +y.html">Pr ivacy</a></p></center></span> <div id=xjsd></div><div id=xjsi><script> +if(google. y)google.y.first=[];google.dlj=function(b){window.setTimeout(function( +){var a=do cument.createElement("script");a.src=b;document.getElementById("xjsd") +.appendChi ld(a)},0)}; if(google.y)google.y.first=[];if(!google.xjs){google.dstr=[];google.re +in=[];if(g oogle.timers&&google.timers.load.t){google.timers.load.t.xjsls=new Dat +e().getTim e();}google.dlj(\'/extern_js/f/CgJlbhICdXMgACswRTgALCswWjgALCswDjgALCs +wFzgALCswP DgALCswUTgALCswCjgBQC8sKzAWOAAsKzAZOAAsKzAlOAAsKzBBOAAsKzBNOAAsKzBOOAA +sKzBUOAAsK zBjOAAsKzBpOAAsKzCOATgALCswGDgALCswJjgAmgIDd3RtLIACUJACSg/VHO6guKrhfo. +js\');goog le.xjs=1}google.neegg=1;google.mc=[];google.mc=google.mc.concat([[69,{ +}],[14,{}] ,[60,{}],[81,{}],[78,{}],[25,{"m":{"bks":true,"blg":true,"dsc":true,"e +vn":true," flm":true,"frm":true,"isch":true,"klg":true,"mbl":true,"nws":true,"plc +s":true,"p pl":true,"prc":true,"pts":true,"rcp":true,"shop":true,"vid":true},"t": +null}],[10 5,{}],[22,{"m_errors":{"32":"Sorry, no more results to show.","default +":"\\u003C font color=red\\u003EError:\\u003C/font\\u003E The server could not co +mplete you r request. Try again in 30 seconds."},"m_tip":"Click for more informa +tion"}],[7 7,{}],[84,{}],[99,{}],[142,{}],[24,{}],[38,{}]]);google.y.first.push(f +unction(){ try{var form=document.f||document.f||document.gs||document.gbqf;google +.ac.i(form ,form.q,\'\',\'\',\'\',{p:1,sw:1,o:1,i:1,l:1,c:1});}catch(e){google.ml +(e,false,{ \'cause\':\'defer\'});}if(google.med){google.med(\'init\');google.init +History(); google.med(\'history\');}google.History&&google.History.initialize(\'/ +\')});if(g oogle.j&&google.j.en&&google.j.xi){window.setTimeout(google.j.xi,0);}< +/script></ div><script>(function(){var a,b=window.location.href.match(/\\/webhp\\ +?[^#]*tune =[^#]*/);if(a=b&&b.length>0?"http://www.google.com/logos/2011/lespaul. +html#"+b[0 ].substr(7):null)google.nav&&google.nav.go?google.nav.go(a):window.loc +ation.href =a;})();</script><script>(function(){ var b,d,e,f;function g(a,c){if(a.removeEventListener){a.removeEventLis +tener("loa d",c,false);a.removeEventListener("error",c,false)}else{a.detachEvent( +"onload",c );a.detachEvent("onerror",c)}}function h(a){f=(new Date).getTime();++d +;a=a||wind ow.event;var c=a.target||a.srcElement;g(c,h)}var i=document.getElement +sByTagName ("img");b=i.length;d=0;for(var j=0,k;j<b;++j){k=i[j];if(k.complete||ty +peof k.src !="string"||!k.src)++d;else if(k.addEventListener){k.addEventListener( +"load",h,f alse);k.addEventListener("error", h,false)}else{k.attachEvent("onload",h);k.attachEvent("onerror",h)}}e= +b-d;functi on l(){if(!google.timers.load.t)return;google.timers.load.t.ol=(new Da +te).getTim e();google.timers.load.t.iml=f;google.kCSI.imc=d;google.kCSI.imn=b;goo +gle.kCSI.i mp=e;google.timers.load.t.xjs&&google.report&&google.report(google.tim +ers.load,g oogle.kCSI)}if(window.addEventListener)window.addEventListener("load", +l,false);e lse if(window.attachEvent)window.attachEvent("onload",l);google.timers +.load.t.pr t=(f=(new Date).getTime()); })(); </script>', '_rc' => '200', '_headers' => bless( { 'x-meta-robots' => 'noodp', 'connection' => 'close', 'set-cookie' => [ 'PREF=ID=b14 +a5245a42e2 690:FF=0:TM=1313519237:LM=1313519237:S=2UrJQIn2iwHfYVhL; expires=Thu, +15-Aug-201 3 18:27:17 GMT; path=/; domain=.google.com', 'NID=50=yPFC +219p-nOY5I OAn_eti4fudJhMTDntXxtug11Qi0BiA0mg4lISBDL1mDrTKSAJ5N2ELexXeTanS-pq21rF +_vUO1zYpWj f2DtMHgxuv4dwJzBbM8CpRwfb3q7eaxsF6; expires=Wed, 15-Feb-2012 18:27:17 +GMT; path= /; domain=.google.com; HttpOnly' ], 'cache-control' => 'private, m +ax-age=0', 'date' => 'Tue, 16 Aug 2011 18 +:27:17 GMT ', 'client-ssl-cert-issuer' => '/ +C=US/O=Goo gle Inc/CN=Google Internet Authority', 'client-ssl-cipher' => 'RC4-SH +A', 'client-peer' => '74.125.229.3 +6:443', 'client-date' => 'Tue, 16 Aug +2011 18:27 :09 GMT', 'content-type' => 'text/html; +charset=IS O-8859-1', 'x-xss-protection' => '1; mode +=block', 'server' => 'gws', 'client-ssl-socket-class' => ' +IO::Socket ::SSL', 'x-meta-description' => 'Searc +h the worl d\'s information, including webpages, images, videos and more. Google +has many s pecial features to help you find exactly what you\'re looking for.', 'client-response-num' => 1, 'client-ssl-cert-subject' => ' +/C=US/ST=C alifornia/L=Mountain View/O=Google Inc/CN=*.google.com', 'title' => 'Google', 'expires' => '-1' }, 'HTTP::Headers' ), '_previous' => bless( { '_protocol' => 'HTTP/1.1', '_content' => '<HTML><HEAD><m +eta http-e quiv="content-type" content="text/html;charset=utf-8"> <TITLE>302 Moved</TITLE></HEAD><BODY> <H1>302 Moved</H1> The document has moved <A HREF="https://encrypted.google.com/">here</A>. </BODY></HTML> ', '_rc' => '302', '_headers' => bless( { 'conne +ction' => 'close', 'set-c +ookie' => 'PREF=ID=4be28478f8645887:FF=0:TM=1313519237:LM=1313519237:S=_s3v6fPd4 +ugYkCvi; e xpires=Thu, 15-Aug-2013 18:27:17 GMT; path=/; domain=.google.com', 'cache +-control' => 'private', 'date' + => 'Tue, 16 Aug 2011 18:27:17 GMT', 'clien +t-ssl-cert -issuer' => '/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA', 'clien +t-ssl-ciph er' => 'RC4-SHA', 'clien +t-peer' => '74.125.229.51:443', 'clien +t-date' => 'Tue, 16 Aug 2011 18:27:09 GMT', 'conte +nt-type' = > 'text/html; charset=UTF-8', 'x-xss +-protectio n' => '1; mode=block', 'serve +r' => 'gws ', 'clien +t-ssl-sock et-class' => 'IO::Socket::SSL', 'locat +ion' => 'h ttps://encrypted.google.com/', 'clien +t-response -num' => 1, 'conte +nt-length' => '226', 'clien +t-ssl-cert -subject' => '/C=US/ST=California/L=Mountain View/O=Google Inc/CN=www. +google.com ', 'title +' => '302 Moved' }, 'HTTP +::Headers' ), '_msg' => 'Found', '_request' => bless( { '_cont +ent' => '' , '_uri' + => bless( do{\(my $o = 'https://www.google.com')}, 'URI::https' ), '_head +ers' => bl ess( { 'user-agent' => 'LWP' }, 'HTTP::Headers' ), '_meth +od' => 'GE T', '_uri_ +canonical' => bless( do{\(my $o = 'https://www.google.com/')}, 'URI::https' ) }, 'HTTP +::Request' ) }, 'HTTP::Response' ), '_msg' => 'OK', '_request' => bless( { '_protocol' => undef, '_content' => '', '_uri' => bless( do{\(my $o = +'https://e ncrypted.google.com/')}, 'URI::https' ), '_headers' => bless( { 'user-a +gent' => ' LWP' }, 'HTTP: +:Headers' ), '_method' => 'GET', '_uri_canonical' => $VAR1->{'_ +request'}{ '_uri'} }, 'HTTP::Request' ) }, 'HTTP::Response' );

From the packed exe

$VAR1 = bless( { '_content' => 'Can\'t connect to www.google.com:443 ', '_rc' => 500, '_headers' => bless( { 'client-warning' => 'Internal +response', 'client-date' => 'Tue, 16 Aug +2011 18:27 :24 GMT', 'content-type' => 'text/plain' }, 'HTTP::Headers' ), '_msg' => 'Can\'t connect to www.google.com:443', '_request' => bless( { '_content' => '', '_uri' => bless( do{\(my $o = +'https://w ww.google.com')}, 'URI::https' ), '_headers' => bless( { 'user-a +gent' => ' LWP' }, 'HTTP: +:Headers' ), '_method' => 'GET' }, 'HTTP::Request' ) }, 'HTTP::Response' );

Replies are listed 'Best First'.
Re: Again with PAR::Packer troubles
by zentara (Archbishop) on Aug 16, 2011 at 16:04 UTC
    I *suspect* there's something that I need to pass to pp as a module that scandeps isn't picking up on, but I'm at a loss to discover what it is.

    Maybe

    use Crypt::SSLeay;
    I've seen that in most WWW::Mechanize programs that use https.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      I've edited the code above to reflect what I'm using now. Still no joy.
Re: Again with PAR::Packer troubles
by Anonymous Monk on Aug 17, 2011 at 10:25 UTC
    Add
    use IO::Socket::SSL qw(debug99);
    and you'll get this from a.exe
    DEBUG: IO/Socket/SSL.pm:1213: Invalid certificate authority locationse +rror:02001003:system library:fopen:No such process SSL error: 1724: 1 - error:2006D080:BIO routines:BIO_new_file:no such + file SSL error: 1724: 2 - error:0B084002:x509 certificate routines:X509_lo +ad_cert_crl_file:system lib

    Problem, PAR doesn't know about C:\perl\site\5.14.1\lib\Mozilla\CA\cacert.pem, it doesn't pack it along with C:\perl\site\5.14.1\lib\Mozilla\CA.pm

    Solution, add the file with

    -a "C:\perl\site\5.14.1\lib\Mozilla\CA\cacert.pem;cacert.pem"

    then in your .pl tell LWP about it

    $ENV{PERL_LWP_SSL_CA_FILE} = File::Spec->catdir( $ENV{PAR_TEMP}, 'cacert.pem');

    update: After testing, I see cacert.pem doesn't end up in root, so you'd have to something like

    $ENV{PERL_LWP_SSL_CA_FILE} = File::Spec->catdir( $ENV{PAR_TEMP}, qw[ i +nc perl site 5.14.1 lib Mozilla CA cacert.pem ] );

    Or specify a path where to install, like -a "C:\perl\site\5.14.1\lib\Mozilla\CA\cacert.pem;/cacert.pem" forget it, you'd have to use PAR::read_file for it to get unpacked, bah caveats

    If Mozilla::CA had used File::ShareDir, you would simply add use File::ShareDir::PAR; to your .pl and it would just work

    So, the bugs are as follows

    • IO::Socket::SSL doesn't give a useful error message to LWP::Protocol::https, so LWP can't give you a useful error message -- you shouldn't need debuging to learn which critical/fatal error occurred
    • Mozilla::CA doesn't use File::ShareDir
    • PAR doesn't automagically add File::ShareDir::PAR when it detects File::ShareDir
    • File::ShareDir::PAR is still experimental :)
    • PAR doesn't have an option to detect/pack  ssleay32.dll libeay32.dll

      The certificate file was the lynchpin.

      PP command:

      pp mech_test.pl -l \Perl\lib\Mozilla\CA\cacert.pm

      I've dealt with having to find files that I've had to include in PP built packages before. Here's how to deal with this particular one:

      use File::Spec; if (exists $ENV{PAR_PROGNAME}) { $ENV{PERL_LWP_SSL_CA_FILE} = File::Spec->catfile( $ENV{PAR_TEMP}, 'cacert.pem' ); }

      I can't remember where I got that gem from, but it helped me when I was first starting to build Tkx apps. In my case, I stick this in a BEGIN block, so that the environment is right before I do anything else.

      Thank you all for your patience and help.

    Re: Again with PAR::Packer troubles
    by Anonymous Monk on Aug 16, 2011 at 21:08 UTC

    Log In?
    Username:
    Password:

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

    How do I use this?Last hourOther CB clients
    Other Users?
    Others meditating upon the Monastery: (6)
    As of 2024-03-19 02:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found