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

G'day Monks.

Today's teaser is a problem with MOP.pm ver 1.04 (squeeze) that works in ver 0.95 .

It seems that it won't load ACME/EAD/Processor.pm, but I can't see why, and the error is just a bit bizzarre!

This is all the output:
Class::MOP::Class::Immutable::Trait #### Class/MOP/Class/Immutable/Trait.pm **** ACME::EAD::Processor #### ACME/EAD/Processor.pm **** Couldn't load class (ACME::EAD::Processor) because: ArrayRef[ReadableD +ir] contains invalid characters for a type name. Names can contain al +phanumeric character, ":", and "." Compilation failed in require at /usr/share/perl5/ACME/EAD/Processor.p +m line 3. BEGIN failed--compilation aborted at /usr/share/perl5/ACME/EAD/Process +or.pm line 3. Compilation failed in require at /usr/lib/perl5/Class/MOP.pm line 118. at /usr/lib/perl5/Class/MOP.pm line 124 Class::MOP::__ANON__('ArrayRef[ReadableDir] contains invalid c +haracters for a type ...') called at /usr/share/perl5/Try/Tiny.pm lin +e 98 Try::Tiny::try('CODE(0xa0375b0)', 'Try::Tiny::Catch=REF(0xa571 +570)') called at /usr/lib/perl5/Class/MOP.pm line 129 Class::MOP::load_first_existing_class('ACME::EAD::Processor') +called at /usr/lib/perl5/Class/MOP.pm line 141 Class::MOP::load_class('ACME::EAD::Processor', undef) called a +t /usr/lib/perl5/Moose/Meta/Class.pm line 288 Moose::Meta::Class::superclasses(undef, 'ACME::EAD::Processor' +) called at /usr/lib/perl5/Moose.pm line 54 Moose::extends('Moose::Meta::Class=HASH(0xa4e7fa0)', 'ACME::EA +D::Processor') called at /usr/lib/perl5/Moose/Exporter.pm line 294 Moose::extends('ACME::EAD::Processor') called at /usr/share/pe +rl5/ACME/EAD/TAM/Processor.pm line 10 require ACME/EAD/TAM/Processor.pm called at /avprog/bin/proces +s_eadesi_tam.pl line 4 main::BEGIN() called at /usr/share/perl5/ACME/EAD/TAM/Processo +r.pm line 0 eval {...} called at /usr/share/perl5/ACME/EAD/TAM/Processor.p +m line 0 Compilation failed in require at /avprog/bin/process_eadesi_tam.pl lin +e 4. BEGIN failed--compilation aborted at /avprog/bin/process_eadesi_tam.pl + line 4.
The error is in this segement :
my $file = _class_to_pmfile($name); print "$file ****\n"; return $name if try { local $SIG{__DIE__}; require $file; $name->VERSION($options->{-version}) if defined $options->{-version}; return 1; } catch { unless (/^Can't locate \Q$file\E in \@INC/) { confess "Couldn't load class ($name) because: $_"; } return; }; }

Replies are listed 'Best First'.
Re: Moose - MOP.pm funny
by chrestomanci (Priest) on Mar 09, 2011 at 16:49 UTC

    Your code segment is not very helpful, as all it is is a wrapper for importing a perl library.

    From the error message, I think Moose is having a problem with something in ACME::EAD::Processor. It looks like the type declaration of ReadableDir is invalid, but seeing as I don't have the source of ACME::EAD::Processor, I can only guess.

    Can you paste in the source of ACME::EAD::Processor, or provide a link, so that we can help you better?

      Ah, OK. That points to use Avbrief::TypeConstraints; There is a comment in this file that looks promising - So I deleted the 'old' lines as described

      =head1 ArrayRefs of types this feature was added to Moose sometime after 0.17 which shipped with + etch please uncomment the lines below when our system have migrated to lenn +y or a later Moose Moose::Util::TypeConstraints->create_parameterized_type_constraint ('A +rrayRef[ReadableDir]'); Moose::Util::TypeConstraints->create_parameterized_type_constraint ('A +rrayRef[WritableDir]'); Moose::Util::TypeConstraints->create_parameterized_type_constraint ('A +rrayRef[ReadableFile]'); Moose::Util::TypeConstraints->create_parameterized_type_constraint ('A +rrayRef[WritableFile]'); Moose::Util::TypeConstraints->create_parameterized_type_constraint ('A +rrayRef[WritablePath]'); Moose::Util::TypeConstraints->create_parameterized_type_constraint ('A +rrayRef[File]'); Moose::Util::TypeConstraints->create_parameterized_type_constraint ('A +rrayRef[Dir]'); then you can delete the types defined the 'old' way below =cut subtype 'ArrayRef[ReadableDir]' => as 'ArrayRef' => where { foreach(@$_) { return unless -d $_; return unless -r $_; } return 1; } => message { "One of the directorys in the array is not readable!" }; subtype 'ArrayRef[WritableDir]' => as 'ArrayRef' => where { etc etc etc
      And now get
      Class::MOP::Class::Immutable::Trait #### Class/MOP/Class/Immutable/Trait.pm **** Avbrief::EAD::Processor #### Avbrief/EAD/Processor.pm **** Couldn't load class (Avbrief::EAD::Processor) because: Could not parse + type name (Moose::Util::TypeConstraints) correctly at /usr/lib/perl5 +/Moose/Util/TypeConstraints.pm line 104 Moose::Util::TypeConstraints::create_parameterized_type_constr +aint('Moose::Util::TypeConstraints', 'ArrayRef[ReadableDir]') called +at /usr/share/perl5/Avbrief/TypeConstraints.pm line 72 require Avbrief/TypeConstraints.pm called at /usr/share/perl5/ +Avbrief/EAD/Processor.pm line 3 Avbrief::EAD::Processor::BEGIN() called at /usr/share/perl5/Av +brief/TypeConstraints.pm line 0 eval {...} called at /usr/share/perl5/Avbrief/TypeConstraints. +pm line 0 require Avbrief/EAD/Processor.pm called at /usr/lib/perl5/Clas +s/MOP.pm line 118 Class::MOP::__ANON__() called at /usr/share/perl5/Try/Tiny.pm +line 71 eval {...} called at /usr/share/perl5/Try/Tiny.pm line 67 Try::Tiny::try('CODE(0x9a2e5b0)', 'Try::Tiny::Catch=REF(0x9f68 +570)') called at /usr/lib/perl5/Class/MOP.pm line 129 Class::MOP::load_first_existing_class('Avbrief::EAD::Processor +') called at /usr/lib/perl5/Class/MOP.pm line 141 Class::MOP::load_class('Avbrief::EAD::Processor', undef) calle +d at /usr/lib/perl5/Moose/Meta/Class.pm line 288 Moose::Meta::Class::superclasses(undef, 'Avbrief::EAD::Process +or') called at /usr/lib/perl5/Moose.pm line 54 Moose::extends('Moose::Meta::Class=HASH(0x9edefa0)', 'Avbrief: +:EAD::Processor') called at /usr/lib/perl5/Moose/Exporter.pm line 294 Moose::extends('Avbrief::EAD::Processor') called at /usr/share +/perl5/Avbrief/EAD/TAM/Processor.pm line 10 require Avbrief/EAD/TAM/Processor.pm called at /avprog/bin/pro +cess_eadesi_tam.pl line 4 main::BEGIN() called at /usr/share/perl5/Avbrief/TypeConstrain +ts.pm line 0 eval {...} called at /usr/share/perl5/Avbrief/TypeConstraints. +pm line 0 Compilation failed in require at /usr/share/perl5/Avbrief/EAD/Processo +r.pm line 3. BEGIN failed--compilation aborted at /usr/share/perl5/Avbrief/EAD/Proc +essor.pm line 3. Compilation failed in require at /usr/lib/perl5/Class/MOP.pm line 118. at /usr/lib/perl5/Class/MOP.pm line 124 Class::MOP::__ANON__('Could not parse type name (Moose::Util:: +TypeConstraints) corr...') called at /usr/share/perl5/Try/Tiny.pm lin +e 98 Try::Tiny::try('CODE(0x9a2e5b0)', 'Try::Tiny::Catch=REF(0x9f68 +570)') called at /usr/lib/perl5/Class/MOP.pm line 129 Class::MOP::load_first_existing_class('Avbrief::EAD::Processor +') called at /usr/lib/perl5/Class/MOP.pm line 141 Class::MOP::load_class('Avbrief::EAD::Processor', undef) calle +d at /usr/lib/perl5/Moose/Meta/Class.pm line 288 Moose::Meta::Class::superclasses(undef, 'Avbrief::EAD::Process +or') called at /usr/lib/perl5/Moose.pm line 54 Moose::extends('Moose::Meta::Class=HASH(0x9edefa0)', 'Avbrief: +:EAD::Processor') called at /usr/lib/perl5/Moose/Exporter.pm line 294 Moose::extends('Avbrief::EAD::Processor') called at /usr/share +/perl5/Avbrief/EAD/TAM/Processor.pm line 10 require Avbrief/EAD/TAM/Processor.pm called at /avprog/bin/pro +cess_eadesi_tam.pl line 4 main::BEGIN() called at /usr/share/perl5/Avbrief/EAD/TAM/Proce +ssor.pm line 0 eval {...} called at /usr/share/perl5/Avbrief/EAD/TAM/Processo +r.pm line 0 Compilation failed in require at /avprog/bin/process_eadesi_tam.pl lin +e 4. BEGIN failed--compilation aborted at /avprog/bin/process_eadesi_tam.pl + line 4.

        create_parameterized_type_constraint is not a method.

        Moose::Util::TypeConstraints->create_parameterized_type_constraint(... +)

        should be

        Moose::Util::TypeConstraints::create_parameterized_type_constraint(... +)

        I wonder what purpose calling create_parameterized_type_constraint would have. Maybe it has side-effects?

        I think you can delete both the "old" way and the commented way.

      package Avbrief::EAD::Processor; use Moose; use Avbrief::TypeConstraints; our $VERSION = 3.00; has file => (isa=>'ReadableFile', is=>'ro', required=>1); has logger => (isa=>'Logger', is=>'ro', required=>1, handles=>[qw/log +error debug/]); has schema => (isa=>'Avbrief::DataLayer::DBIC', is=>'ro'); sub process { die "overide me!" }; 1;
      Let me know if you need anything else - I'm not a perl developer!
        Line 3 is use Avbrief::TypeConstraints;, so the error is in Avbrief::TypeConstraints. Unfortunately, we don't have a line number for the actual error.
Re: Moose - MOP.pm funny
by ikegami (Patriarch) on Mar 09, 2011 at 16:59 UTC
    The message says the error occurred at ACME/EAD/Processor.pm line 3.