Subject: | Catalyst::Utils - "require $class was successful but the package is not defined" when using Moose::Utils::TypeConstraints |
Date: | Thu, 24 Feb 2011 23:16:42 +0000 |
To: | bug-Catalyst-Runtime [...] rt.cpan.org |
From: | Noel <noel.dolan [...] atlantisstorm.com> |
Hi,
There seems to be bug or at least a misleading warning (noted to be
fatal error in future versions) when using Moose::Utils::TypeConstraints
with Catalyst in the following context.
#-------------------------------------------------------------------------------------
# Environment
#-------------------------------------------------------------------------------------
linux (ubuntu 8.04 - hardy heron)
perl -v 5.8.8
Catalyst 5.80029
Catalyst::Utils <not defined>
Moose 1.23
Moose::Util::TypeConstraints 1.23
#-------------------------------------------------------------------------------------
# Test
#-------------------------------------------------------------------------------------
# 01. Create Uji/Test.
catalyst.pl Uji
# Confirm uji_server loads properly.
./script/uji_server.pl ( should load with no warnings)
# 02. Create empty class - lib/Uji/Model/Types.pm
package Uji::Model::Types.pm
use Moose;
1;
# 03. Confirm uji_server loads properly.
./script/uji_server.pl ( should load with no warnings)
# 04. Replace lib/Uji/Model/Types.pm contents as follows.
package Uji::Model::Types;
use Moose::Util::TypeConstraints;
subtype 'Uji::Model::Types::Reference' => as 'Str'
=> where { $_ =~
/^\d{8}\-[A-Z]{3}\-\d{3}$/ }
=> message { "'$_' is not a
valid Tempest::Model::Types::Reference" };
no Moose::Util::TypeConstraints;
1;
# 05. Confirm uji_server loads properly.
./script/uji_server.pl ( Results in warning/error message "require
Uji::Model::Types was successful but the package is not defined. at
/usr/local/share/perl/5.8.8/Catalyst/Utils.pm line 293." )
#-------------------------------------------------------------------------------------
The text on
http://search.cpan.org/dist/Catalyst-Runtime/lib/Catalyst/Upgrading.pod
seems to suggest there is a problem with package name.
Class files with names that don't correspond to the packages they define
<http://search.cpan.org/dist/Catalyst-Runtime/lib/Catalyst/Upgrading.pod#___top>
In this version of Catalyst, if a component is loaded from disk, but no
symbols are defined in that component's name space after it is loaded,
this warning will be issued:
require $class was successful but the package is not defined.
This is to protect against confusing bugs caused by mistyping package
names, and will become a fatal error in a future version.
#-------------------------------------------------------------------------------------
So is this a bug, or just misuse/misunderstanding? (Relatively new to
Catalyst, so apologises if it is something very obvious)