Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

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

Refactoring a 2006 perl cgi application (based on a 1999 php application) as a Mojolicious app, with the Moose having been introduced by earlier development, I have just in the last dozen commits begun to introduce Mojo to the mix. After a handful of successful tests with a Mojo::Lite app, as I make the transition to a non-Lite app, on my way to supporting the legacy features, I seem plagued by errors looking like this:

List::Util version 1.45 required--this is only version 1.38 at local/l +ib/perl5/x86_64-linux-gnu-thread-multi/Moose/Exporter.pm line 9. BEGIN failed--compilation aborted at local/lib/perl5/x86_64-linux-gnu- +thread-multi/Moose/Exporter.pm line 9. Compilation failed in require at local/lib/perl5/x86_64-linux-gnu-thre +ad-multi/Moose.pm line 15. BEGIN failed--compilation aborted at local/lib/perl5/x86_64-linux-gnu- +thread-multi/Moose.pm line 15. Compilation failed in require at /opt/local/vote/vagrant/cf_vote/bin/. +./lib/Vote.pm line 5. BEGIN failed--compilation aborted at /opt/local/vote/vagrant/cf_vote/b +in/../lib/Vote.pm line 5. Compilation failed in require at (eval 12) line 1.

having tried a number of strategies, the latest looking like that in the next code block. The grep in the BEGIN block was motivated by an inspection of `Dumper \@INC;` and `locate List/Util.pm | grep -v \.cpanm | xargs grep -i our.*version.*1.38` queries.

#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; use FindBin; BEGIN { unshift @INC, "$FindBin::Bin/../lib", "$FindBin::Bin/../local/lib/pe +rl5", "$FindBin::Bin/../lib/perl5"; @INC = grep { $_ !~ /perl\/5.20.2/ } @INC; } print Dumper \@INC; my $listen_socket = '3000'; my $watch_paths = [ 'lib', 'templates', 'app', '/opt/local/vote' ]; # Start command line interface for application require Mojolicious::Commands; Mojolicious::Commands->start_app('Vote','daemon','-l',"http://*:$liste +n_socket");

the resulting @INC is as expected, excluding the problematic version of List::Util.

$VAR1 = [ '/opt/local/vote/vagrant/cf_vote/bin/../lib', '/opt/local/vote/vagrant/cf_vote/bin/../local/lib/perl5', '/opt/local/vote/vagrant/cf_vote/bin/../lib/perl5', '/etc/perl', '/usr/lib/x86_64-linux-gnu/perl5/5.20', '/usr/share/perl5', '/usr/lib/x86_64-linux-gnu/perl/5.20', '/usr/share/perl/5.20', '/usr/local/lib/site_perl', '.' ];

Running that same locate-xrgs-grep query for version 1.49, shows me:
/opt/local/vote/vagrant/cf_vote/local/lib/perl5/x86_64-linux-gnu-thread-multi/List/Util.pm
which should be served by the second entry in my @INC array:
/opt/local/vote/vagrant/cf_vote/bin/../local/lib/perl5

line 5 of Vote.pm reads `use Moose;` and its context looks like this:

package Vote; use lib qw( lib local/lib/perl5 ); use CGI; use Moose; use MooseX::NonMoose; extends 'Mojolicious::Controller'; use Mojolicious::Plugin::CGI;

The line blowing up in Moose.pm reads: `use Moose::Exporter;', and its context looks like this:

use strict; use warnings; package Moose; # git description: 2.2008-4-gf9468cd8f our $VERSION = '2.2009'; our $AUTHORITY = 'cpan:STEVAN'; use 5.008003; use Scalar::Util (); use Carp 'carp'; use Module::Runtime 'module_notional_filename'; use Class::Load 'is_class_loaded'; use Moose::Deprecated; use Moose::Exporter; use Class::MOP;

And the problematic Moose::Exporter line reads `use List::Util 1.45 qw( uniq );`, in a context of this:

package Moose::Exporter; our $VERSION = '2.2009'; use strict; use warnings; use Class::Load qw(is_class_loaded); use Class::MOP; use List::Util 1.45 qw( uniq ); use Moose::Util::MetaRole; use Scalar::Util 1.11 qw(reftype); use Sub::Exporter 0.980; use Sub::Name qw(subname);

I'm thinking that the v1.49 installed from a cpanfile entry reading: `requires 'List::Util', '1.49';`, ought to satisfy the 1.45 version requirement created by the Exporter, and do not know why the cpanfile libraries in local/lib/perl5 are not read in precedence over any other available libraries in the @INC stack.

What please might I be missing here?

-- Hugh 
if( $lal && $lol ) { $life++; }
if( $insurance->rationing() ) { $people->die(); }

In reply to Mojolicious fails to respect @INC by hesco

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 drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-25 20:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found