Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Moose: inherited attributes

by rootcho (Pilgrim)
on Jan 10, 2014 at 20:26 UTC ( [id://1070187]=perlquestion: print w/replies, xml ) Need Help??

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

Brand new installation .. trying to run my app, but it blows up with the error below.
As you may deduce I have a attribute 'obj_templates' in the parent class and then in the ansestor I override it with '+obj_templates' declaration.
The same app work OK on a different machines with Moose ver : 1.21 and 2.08

What look suspicious to me is this part of the msg.. there is no module named after "from" ?!
Also if I disable the attr in the parent and remove the '+' in the ansestor it works.
to inherit from in VS::Payload::Postal

Any idea how can I resolve or even start to debug this problem ?
Here is the error I get in version 2.1200 :

Could not find an attribute by the name of 'obj_templates' to inherit +from in VS::Payload::Postal at /home/raptor/perl5/perlbrew/perls/perl +-5.18.2/lib/site_perl/5.18.2/x86_64-linux/Moose/Exception.pm line 38 Moose::Exception::_build_trace('Moose::Exception::NoAttributeFound +InSuperClass=HASH(0x245be10)') called at reader Moose::Exception::tra +ce (defined at /home/raptor/perl5/perlbrew/perls/perl-5.18.2/lib/site +_perl/5.18.2/x86_64-linux/Moose/Exception.pm line 12) line 7 Moose::Exception::trace('Moose::Exception::NoAttributeFoundInSuper +Class=HASH(0x245be10)') called at /home/raptor/perl5/perlbrew/perls/p +erl-5.18.2/lib/site_perl/5.18.2/x86_64-linux/Moose/Exception.pm line +50 Moose::Exception::BUILD('Moose::Exception::NoAttributeFoundInSuper +Class=HASH(0x245be10)', 'HASH(0x240dc40)') called at /home/raptor/per +l5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/x86_64-linux/Class +/MOP/Method.pm line 131 Class::MOP::Method::execute('Moose::Meta::Method=HASH(0x24d0808)', + 'Moose::Exception::NoAttributeFoundInSuperClass=HASH(0x245be10)', 'H +ASH(0x240dc40)') called at /home/raptor/perl5/perlbrew/perls/perl-5.1 +8.2/lib/site_perl/5.18.2/x86_64-linux/Moose/Object.pm line 59 Moose::Object::BUILDALL('Moose::Exception::NoAttributeFoundInSuper +Class=HASH(0x245be10)', 'HASH(0x240dc40)') called at /home/raptor/per +l5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/x86_64-linux/Moose +/Meta/Class.pm line 285 Moose::Meta::Class::new_object('Moose::Meta::Class=HASH(0x245c050) +', 'HASH(0x240dc40)') called at /home/raptor/perl5/perlbrew/perls/per +l-5.18.2/lib/site_perl/5.18.2/x86_64-linux/Moose/Object.pm line 30 Moose::Object::new('Moose::Exception::NoAttributeFoundInSuperClass +', 'class', 'Moose::Meta::Class=HASH(0x2222158)', 'attribute_name', ' +obj_templates', 'params', 'HASH(0x1078580)') called at /home/raptor/p +erl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/x86_64-linux/Moo +se/Util.pm line 54 Moose::Util::throw_exception('NoAttributeFoundInSuperClass', 'clas +s', 'Moose::Meta::Class=HASH(0x2222158)', 'attribute_name', 'obj_temp +lates', 'params', 'HASH(0x1078580)') called at /home/raptor/perl5/per +lbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/x86_64-linux/Moose/Meta/ +Class.pm line 726 Moose::Meta::Class::_process_inherited_attribute('Moose::Meta::Cla +ss=HASH(0x2222158)', 'obj_templates', 'definition_context', 'HASH(0x2 +417890)', 'default', 'CODE(0x23dbd60)') called at /home/raptor/perl5/ +perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/x86_64-linux/Moose/Me +ta/Class.pm line 709 Moose::Meta::Class::_process_attribute('Moose::Meta::Class=HASH(0x +2222158)', '+obj_templates', 'definition_context', 'HASH(0x2417890)', + 'default', 'CODE(0x23dbd60)') called at /home/raptor/perl5/perlbrew/ +perls/perl-5.18.2/lib/site_perl/5.18.2/x86_64-linux/Moose/Meta/Class. +pm line 576 Moose::Meta::Class::add_attribute('Moose::Meta::Class=HASH(0x22221 +58)', '+obj_templates', 'definition_context', 'HASH(0x2417890)', 'def +ault', 'CODE(0x23dbd60)') called at /home/raptor/perl5/perlbrew/perls +/perl-5.18.2/lib/site_perl/5.18.2/x86_64-linux/Moose.pm line 80 Moose::has('Moose::Meta::Class=HASH(0x2222158)', '+obj_templates', + 'default', 'CODE(0x23dbd60)') called at /home/raptor/perl5/perlbrew/ +perls/perl-5.18.2/lib/site_perl/5.18.2/x86_64-linux/Moose/Exporter.pm + line 408 Moose::has('+obj_templates', 'default', 'CODE(0x23dbd60)') called +at ../base/lib/VS/Payload/Postal.pm line 15 require VS/Payload/Postal.pm at ../lib/VS/App/SRC3.pm line 8 VS::App::SRC3::BEGIN at ../base/lib/VS/Payload/Postal.pm line 0 eval {...} at ../base/lib/VS/Payload/Postal.pm line 0 require VS/App/SRC3.pm at src3.pl line 4 main::BEGIN at ../base/lib/VS/Payload/Postal.pm line 0 eval {...} at ../base/lib/VS/Payload/Postal.pm line 0 Compilation failed in require at ../lib/VS/App/SRC3.pm line 8. BEGIN failed--compilation aborted at ../lib/VS/App/SRC3.pm line 8. Compilation failed in require at src3.pl line 4. BEGIN failed--compilation aborted at src3.pl line 4.

Replies are listed 'Best First'.
Re: Moose: inherited attributes
by tobyink (Canon) on Jan 10, 2014 at 23:57 UTC

    Moose's error messages are notoriously bad. There's often a helpful line, but it's usually buried in a hundred other unhelpful ones.

    You haven't shown any source code, so the best I can do is take a wild stab in the dark.

    One biggish change between Moose 2.08 and 2.12 is the way that Moose decides whether a class is loaded or not. In older versions of Moose it used various interesting heuristics. In newer versions it uses the simpler policy of checking %INC.

    Your VS::Payload::Postal class inherits from some base class. Is this base class in an appropriately named module file - i.e. if the base class is called Foo::Bar, then is it defined in a file called "Foo/Bar.pm", and stored in a directory listed in @INC?

    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
      thanks. .No the file names match..
      That is how the code looks..
      VS::Payload has 'obj_templates', is => 'rw', isa => 'HashRef'; VS::Payload::Postal has '+obj_templates', is => 'rw', default => sub{{ .... }};

      It works if I change it to this :
      VS::Payload #has 'obj_templates', is => 'rw', isa => 'HashRef'; VS::Payload::Postal has 'obj_templates', is => 'rw', default => sub{{ .... }};

      i.e. it behaves as if I have not declared anything in the parent class.
Re: Moose: inherited attributes
by educated_foo (Vicar) on Jan 11, 2014 at 02:14 UTC
    This reminds me of decoding C++ template compiler barf in the 90s, but worse, because it includes random memory addresses you can no longer see, rather than the names of internal templates in libstdc++. C++ compilers are much better these days, so at least there is some hope over the next decade.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-25 22:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found