Subject: | Does not compile with Moose-2.1402: The _header attribute is trying to delegate to a class which has not been loaded - RPM2::Header |
The Archive::RPM2 cannot be compiled with Moose 2.1402. E.g. tests fail like this:
# Failed test 'use Archive::RPM;'
# at t/00-load.t line 4.
# Tried to use 'Archive::RPM'.
# Error: The _header attribute is trying to delegate to a class which has not been loaded - RPM2::Header at /usr/lib64/perl5/vendor_perl/Class/MOP/Class.pm line 901
# Class::MOP::Class::catch {...} ('Moose::Exception::DelegationToAClassWhichIsNotLoaded=HASH(0x49051f0)') called at /usr/share/perl5/vendor_perl/Try/Tiny.pm line 104
# Try::Tiny::try('CODE(0x48efbf0)', 'Try::Tiny::Catch=REF(0x48e7ca8)') called at /usr/lib64/perl5/vendor_perl/Class/MOP/Class.pm line 903
# Class::MOP::Class::_post_add_attribute('Moose::Meta::Class::__ANON__::SERIAL::1=HASH(0x2e420b8)', 'Moose::Meta::Attribute=HASH(0x48e8740)') called at /usr/lib64/perl5/vendor_perl/Class/MOP/Mixin/HasAttributes.pm line 38
# Class::MOP::Mixin::HasAttributes::add_attribute('Moose::Meta::Class::__ANON__::SERIAL::1=HASH(0x2e420b8)', 'Moose::Meta::Attribute=HASH(0x48e8740)') called at /usr/lib64/perl5/vendor_perl/Moose/Meta/Class.pm line 572
# Moose::Meta::Class::add_attribute('Moose::Meta::Class::__ANON__::SERIAL::1=HASH(0x2e420b8)', '_header', 'definition_context', 'HASH(0x48e5a80)', 'is', 'ro', 'isa', 'RPM2::Header', 'lazy_build', 1, 'handles', 'Regexp=REGEXP(0x2c6aec8)') called at /usr/lib64/perl5/vendor_perl/Moose.pm line 76
# Moose::has('Moose::Meta::Class::__ANON__::SERIAL::1=HASH(0x2e420b8)', '_header', 'is', 'ro', 'isa', 'RPM2::Header', 'lazy_build', 1, 'handles', 'Regexp=REGEXP(0x2c6aec8)') called at /usr/lib64/perl5/vendor_perl/Moose/Exporter.pm line 418
# Moose::has('_header', 'is', 'ro', 'isa', 'RPM2::Header', 'lazy_build', 1, 'handles', 'Regexp=REGEXP(0x2c6aec8)') called at /home/test/fedora/perl-Archive-RPM/Archive-RPM-0.07/blib/lib/Archive/RPM.pm line 62
# require Archive/RPM.pm at t/00-load.t line 4
# main::BEGIN at /home/test/fedora/perl-Archive-RPM/Archive-RPM-0.07/blib/lib/Archive/RPM.pm line 0
# eval {...} at /home/test/fedora/perl-Archive-RPM/Archive-RPM-0.07/blib/lib/Archive/RPM.pm line 0
# eval 'package main;
This can be reduce to this code:
$ cat Archive/RPM.pm
package Archive::RPM;
use Moose;
use RPM2 0.67;
has _header => (
is => 'ro',
isa => 'RPM2::Header',
lazy_build => 1,
# http://www.perlmonks.org/?node_id=588315 kick ass!
handles => qr/^(?!(?s:.*)^(files|changelog|nvr)$)/,
);
1;
[test@fedora-22 tmp]$ perl -I. -e 'use Archive::RPM'
The _header attribute is trying to delegate to a class which has not been loaded - RPM2::Header at /usr/lib64/perl5/vendor_perl/Class/MOP/Class.pm line 901
Class::MOP::Class::catch {...} ('Moose::Exception::DelegationToAClassWhichIsNotLoaded=HASH(0x1cdac08)') called at /usr/share/perl5/vendor_perl/Try/Tiny.pm line 104
Try::Tiny::try('CODE(0x1cda758)', 'Try::Tiny::Catch=REF(0x1b88148)') called at /usr/lib64/perl5/vendor_perl/Class/MOP/Class.pm line 903
Class::MOP::Class::_post_add_attribute('Moose::Meta::Class=HASH(0x1a1de38)', 'Moose::Meta::Attribute=HASH(0x1cdace0)') called at /usr/lib64/perl5/vendor_perl/Class/MOP/Mixin/HasAttributes.pm line 38
Class::MOP::Mixin::HasAttributes::add_attribute('Moose::Meta::Class=HASH(0x1a1de38)', 'Moose::Meta::Attribute=HASH(0x1cdace0)') called at /usr/lib64/perl5/vendor_perl/Moose/Meta/Class.pm line 572
Moose::Meta::Class::add_attribute('Moose::Meta::Class=HASH(0x1a1de38)', '_header', 'definition_context', 'HASH(0x19e6c48)', 'is', 'ro', 'isa', 'RPM2::Header', 'lazy_build', 1, 'handles', 'Regexp=REGEXP(0x1b5b0e0)') called at /usr/lib64/perl5/vendor_perl/Moose.pm line 76
Moose::has('Moose::Meta::Class=HASH(0x1a1de38)', '_header', 'is', 'ro', 'isa', 'RPM2::Header', 'lazy_build', 1, 'handles', 'Regexp=REGEXP(0x1b5b0e0)') called at /usr/lib64/perl5/vendor_perl/Moose/Exporter.pm line 418
Moose::has('_header', 'is', 'ro', 'isa', 'RPM2::Header', 'lazy_build', 1, 'handles', 'Regexp=REGEXP(0x1b5b0e0)') called at Archive/RPM.pm line 6
require Archive/RPM.pm at -e line 1
main::BEGIN at Archive/RPM.pm line 0
eval {...} at Archive/RPM.pm line 0
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
If you comment out the "handle" attribute, it will pass.
Recent Moose seems not able to enumerate subroutines of a module which has not been loaded explicitly (use RPM2::Header). The RPM2::Header resides in RPM2.pm file.