[Catalyst] Argh! Trying to upgrade Catalyst -- getting "Can't use string as a HASH ref..."

Tomas Doran bobtfish at bobtfish.net
Sun Mar 31 15:00:33 GMT 2013


Hmm.

Class::Accessor::Fast should not be being used - I'd guess that you might have an outdated plugin?

What does your application class look like, and does running the Makefile.PL of Catalyst-Runtime tell you to upgrade any plugins?

Cheers
t0m

On 31 Mar 2013, at 02:21, will trillich <will.trillich at serensoft.com> wrote:

> $ perl -wMDevel::SimpleTrace script/waste_web_server.pl 
> Duplicate specification "host|h=s" for option "h"
>         at Catalyst::ScriptRole::_getopt_spec_warnings(unknown source)
>         at MooseX::Getopt::Basic::_parse_argv(/usr/local/share/perl/5.10.1/MooseX/Getopt/Basic.pm:138)
>         at MooseX::Getopt::Basic::process_argv(/usr/local/share/perl/5.10.1/MooseX/Getopt/Basic.pm:79)
>         at MooseX::Getopt::Basic::new_with_options(/usr/local/share/perl/5.10.1/MooseX/Getopt/Basic.pm:105)
>         at Catalyst::ScriptRunner::run(/usr/local/share/perl/5.10.1/Catalyst/ScriptRunner.pm:50)
>         at main::(script/waste_web_server.pl:8)
> Can't use string ("Waste::Web") as a HASH ref while "strict refs" in use at /usr/share/perl5/Class/Accessor/Fast.pm line 10.
> Compilation failed in require
>         at Carp::croak(/usr/local/share/perl/5.10.1/Catalyst/ScriptRunner.pm:50)
>         at Class::Load::_croak(/usr/local/share/perl/5.10.1/Class/Load.pm:200)
>         at Class::Load::load_class(/usr/local/share/perl/5.10.1/Class/Load.pm:41)
>         at Catalyst::ScriptRole::_run_application(/usr/local/share/perl/5.10.1/Catalyst/ScriptRole.pm:90)
>         at Catalyst::Script::Server::run(/usr/local/share/perl/5.10.1/Catalyst/Script/Server.pm:240)
>         at Catalyst::ScriptRunner::run(/usr/local/share/perl/5.10.1/Catalyst/ScriptRunner.pm:50)
>         at main::(script/waste_web_server.pl:8)
> 
> So maybe there's something pertinent going on at Catalyst::ScriptRole? (Doubtful, but just in case...)
> 
> MooseX::Getopt::Basic::CODE(0x943d320)(/usr/local/share/perl/5.10.1/MooseX/Getopt/Basic.pm:134):
> 
> DB<3> v
> 131         my ( $parsed_options, $usage ) = try {
> 132:b           local $SIG{__WARN__} = sub { push @warnings, @_ };
> 133     
> 134==>          return $class->_getopt_get_options(\%params, $opt_spec);
> 135         }
> 136         catch {
> 137:            $class->_getopt_spec_exception(\@warnings, $_);
> 138:        };
> 139     
> 140:        $class->_getopt_spec_warnings(@warnings) if @warnings;
> 
> DB<4> x $opt_spec
> 0  ARRAY(0x9897f38)
>    0  ARRAY(0x943cfe0)
>       0  'loader_class=s'
>       1  'The class to use to detect and load the PSGI engine'
>       2  HASH(0x942e650)
>            empty hash
>    1  ARRAY(0x9438a18)
>       0  'help|usage|?|h!'
>       1  'Prints this usage information.'
>       2  HASH(0x94389e8)
>            empty hash
>    2  ARRAY(0x9438688)
>       0  'debug|d!'
>       1  'Force debug mode'
>       2  HASH(0x9441648)
>            empty hash
>    3  ARRAY(0x943dcf0)
>       0  'host|h=s'
>       1  'Specify a hostname or IP on this host for the server to bind to'
>       2  HASH(0x942e850)
>            empty hash
>    4  ARRAY(0x943d420)
>       0  'fork|f!'
>       1  'Fork the server to be able to serve multiple requests at once'
>       2  HASH(0x943d4b0)
>            empty hash
>    5  ARRAY(0x943d4d0)
>       0  'port|p=i'
>       1  'Specify a different listening port (to the default port 3000)'
>       2  HASH(0x943d4f0)
>            empty hash
>    6  ARRAY(0x9a03f38)
>       0  'pidfile|pid=s'
>       1  'Specify a pidfile'
>       2  HASH(0x99f8690)
>            empty hash
>    7  ARRAY(0x99dde10)
>       0  'keepalive|k!'
>       1  'Support keepalive'
>       2  HASH(0x99fdf58)
>            empty hash
>    8  ARRAY(0x99fe838)
>       0  'background|bg!'
>       1  'Run in the background'
>       2  HASH(0x99f0498)
>            empty hash
>    9  ARRAY(0x99f8f00)
>       0  'restart|r!'
>       1  'use Catalyst::Restarter to detect code changes and restart the application'
>       2  HASH(0x99f8ac0)
>            empty hash
>    10  ARRAY(0x99fddc8)
>       0  'restart_directory|rdir|restartdirectory=s@'
>       1  'Restarter directory to watch'
>       2  HASH(0x99f8b40)
>            empty hash
>    11  ARRAY(0x99fe0b8)
>       0  'restart_delay|rd=i'
>       1  'Set a restart delay'
>       2  HASH(0x99fe1d8)
>            empty hash
>    12  ARRAY(0x99f92f0)
>       0  'restart_regex|rr=s'
>       1  'Restart regex'
>       2  HASH(0x99fdb18)
>            empty hash
>    13  ARRAY(0x99f03b8)
>       0  'follow_symlinks|sym!'
>       1  'Follow symbolic links'
>       2  HASH(0x99fe288)
>            empty hash
>    14  ARRAY(0x9a12cd0)
>       0  'restarter_class=s'
>       1  ' '
>       2  HASH(0x99f8680)
>            empty hash
> 
>   DB<5> x \%params
> 0  HASH(0x98782f0)
>    'options' => ARRAY(0x8c68400)
>       0  HASH(0x9441168)
>          'doc' => 'The class to use to detect and load the PSGI engine'
>          'init_arg' => 'loader_class'
>          'name' => 'loader_class'
>          'opt_string' => 'loader_class=s'
>          'required' => undef
>       1  HASH(0x99fdb88)
>          'doc' => 'Prints this usage information.'
>          'init_arg' => 'help_flag'
>          'name' => 'help'
>          'opt_string' => 'help|usage|?|h!'
>          'required' => undef
>       2  HASH(0x935d890)
>          'doc' => 'Force debug mode'
>          'init_arg' => 'debug'
>          'name' => 'debug'
>          'opt_string' => 'debug|d!'
>          'required' => undef
>       3  HASH(0x9441a28)
>          'doc' => 'Specify a hostname or IP on this host for the server to bind to'
>          'init_arg' => 'host'
>          'name' => 'host'
>          'opt_string' => 'host|h=s'
>          'required' => undef   
>       4  HASH(0x9441898)       
>          'doc' => 'Fork the server to be able to serve multiple requests at once'
>          'init_arg' => 'fork'  
>          'name' => 'fork'      
>          'opt_string' => 'fork|f!'
>          'required' => undef   
>       5  HASH(0x9440e98)       
>          'doc' => 'Specify a different listening port (to the default port 3000)'
>          'init_arg' => 'port'  
>          'name' => 'port'      
>          'opt_string' => 'port|p=i'
>          'required' => undef   
>       6  HASH(0x9059388)       
>          'doc' => 'Specify a pidfile'
>          'init_arg' => 'pidfile'
>          'name' => 'pidfile'   
>          'opt_string' => 'pidfile|pid=s'
>          'required' => undef   
>       7  HASH(0x9441798)       
>          'doc' => 'Support keepalive'
>          'init_arg' => 'keepalive'
>          'name' => 'keepalive' 
>          'opt_string' => 'keepalive|k!'
>          'required' => undef   
>       8  HASH(0x9441178)       
>          'doc' => 'Run in the background'
>          'init_arg' => 'background'
>          'name' => 'background'
>          'opt_string' => 'background|bg!'
>          'required' => undef   
>       9  HASH(0x94411a8)       
>          'doc' => 'use Catalyst::Restarter to detect code changes and restart the application'
>          'init_arg' => 'restart'
>          'name' => 'restart'   
>          'opt_string' => 'restart|r!'
>          'required' => undef   
>       10  HASH(0x9441128)      
>          'doc' => 'Restarter directory to watch'
>          'init_arg' => 'restart_directory'
>          'name' => 'restart_directory'
>          'opt_string' => 'restart_directory|rdir|restartdirectory=s@'
>          'required' => undef   
>       11  HASH(0x94411b8)      
>          'doc' => 'Set a restart delay'
>          'init_arg' => 'restart_delay'
>          'name' => 'restart_delay'
>          'opt_string' => 'restart_delay|rd=i'
>          'required' => undef   
>       12  HASH(0x9441028)      
>          'doc' => 'Restart regex'
>          'init_arg' => 'restart_regex'
>          'name' => 'restart_regex'
>          'opt_string' => 'restart_regex|rr=s'
>          'required' => undef   
>       13  HASH(0x943dc10)      
>          'doc' => 'Follow symbolic links'
>          'init_arg' => 'follow_symlinks'
>          'name' => 'follow_symlinks'
>          'opt_string' => 'follow_symlinks|sym!'
>          'required' => undef   
>       14  HASH(0x943d880)      
>          'init_arg' => 'restarter_class'
>          'name' => 'restarter_class'
>          'opt_string' => 'restarter_class=s'
>          'required' => undef   
>    'params' => HASH(0x942e5d0) 
>       'application_name' => 'Waste::Web'
> 
> Looks like a red herring to me... Still quite a puzzle!
> 
> Disabling the cache is allowing the app to launch, so there's that. :( Further pointers welcome!
> 
> 
> On Sat, Mar 30, 2013 at 6:55 PM, Tomas Doran <bobtfish at bobtfish.net> wrote:
> What's the backtrace look like if you load Devel::SimpleTrace or Carp::Always?
> 
> Cheers
> t0m
> 
> On 30 Mar 2013, at 12:04, will trillich <will.trillich at serensoft.com> wrote:
> 
> > We have a Catalyst app "Waste::Web" that has been running fine and we are trying to upgrade to a more modern set of libraries via "cpanm". (One library was upgraded that caused conflicts, now we're running a sweep to get everything updated...)
> >
> > We have an old app called "Spills" that still runs fine. The problem is with a different old app called "Waste::Web"... It won't start, throwing the "can't use string as HASH ref" error, neither as standalone server for testing nor via apache. Suggestions?
> >
> >
> >
> > At first we thought maybe the script formats had changed. So we ran a quick sample "catalyst.pl Catalyst::Upgrade" to come up with the latest structure for comparison. This I'll call "new script" below. Then we looked at the script/*pl files, the lib/* files. None of the structures seem to have changed from what we can tell.
> >
> > That is, the old script/*server.pl script has the same standard structure as the brand new script:
> >
> > #!/usr/bin/env perl
> > BEGIN {
> >    $ENV{CATALYST_SCRIPT_GEN} = 40;
> > }
> > use Catalyst::ScriptRunner;
> > Catalyst::ScriptRunner->run('Waste::Web', 'Server');
> > 1;
> >
> > Comparing lib/Waste/Web.pm (old script) to lib/Catalyst/Upgrade.pm (new script) also looks similar -- commented code redacted for space:
> >
> > package Waste::Web;
> > use Moose;
> > use namespace::autoclean;
> >
> > use Catalyst::Runtime 5.80;
> >
> > use Catalyst qw/
> >    ConfigLoader
> >    Static::Simple
> >        Session
> >        Session::Store::DBIC
> >        Session::State::Cookie
> >        Authentication
> >        Authentication::Credential::Password
> >        Authorization::Roles
> >    Cache
> > /;
> > use Waste::Lib::CSV;
> >
> > extends 'Catalyst';
> >
> > our $VERSION = '1.10';
> >
> > __PACKAGE__->config(
> >    name => 'Waste::Web',
> >    # Disable deprecated behavior needed by old applications
> >    disable_component_resolution_regex_fallback => 1,
> > );
> >
> > # Start the application
> > __PACKAGE__->setup();
> >
> > In the new script there *is* a new option to the __PACKAGE__->config call but it's just to instantiate the X-Catalyst http header. All serious structures look the same.
> >
> > But Catalyst::Upgrade runs just fine, and an old app Spill runs just fine, where Waste::Web throws the error:
> >
> > Waste$ perl script/waste_web_server.pl
> > Can't use string ("Waste::Web") as a HASH ref while "strict refs" in use at /usr/share/perl5/Class/Accessor/Fast.pm line 10.
> > Compilation failed in require at /usr/local/share/perl/5.10.1/Catalyst/ScriptRunner.pm line 50.
> >
> > Waste$ cd ../Catalyst-Upgrade/
> > Catalyst-Upgrade$ perl script/catalyst_upgrade_server.pl
> > HTTP::Server::PSGI: Accepting connections at http://0:3000/
> >
> > Any ideas why we'd be getting this error?
> >
> > Here's the single-step debug log:
> >
> > Catalyst::Script::Server::run(/usr/local/share/perl/5.10.1/Catalyst/Script/Server.pm:240):
> > DB<1> v
> > 237             $self->pidfile->write
> > 238:                if $self->_has_pidfile;
> > 239
> > 240==>          $self->_run_application;
> > 241         }
> > 242
> > 243
> > 244     }
> > 245
> > 246     sub _plack_loader_args {
> >
> > DB<1> s
> > Catalyst::ScriptRole::_run_application(/usr/local/share/perl/5.10.1/Catalyst/ScriptRole.pm:88):
> > 88:         my $self = shift;
> >
> > DB<1> n
> > Catalyst::ScriptRole::_run_application(/usr/local/share/perl/5.10.1/Catalyst/ScriptRole.pm:89):
> > 89:         my $app = $self->application_name;
> >
> > DB<1> n
> > Catalyst::ScriptRole::_run_application(/usr/local/share/perl/5.10.1/Catalyst/ScriptRole.pm:90):
> > 90:         Class::MOP::load_class($app);
> >
> > DB<1> p $app
> > Waste::Web
> >
> > DB<2> n
> > Can't use string ("Waste::Web") as a HASH ref while "strict refs" in use at /usr/share/perl5/Class/Accessor/Fast.pm line 10.
> > Compilation failed in require at /usr/local/share/perl/5.10.1/Catalyst/ScriptRunner.pm line 50.
> > at /usr/local/share/perl/5.10.1/Catalyst/ScriptRole.pm line 90.
> >        Catalyst::ScriptRole::_run_application('Catalyst::Script::Server=HASH(0xa5e1660)') called at /usr/local/share/perl/5.10.1/Catalyst/Script/Server.pm line 240
> >        Catalyst::Script::Server::run('Catalyst::Script::Server=HASH(0xa5e1660)') called at /usr/local/share/perl/5.10.1/Catalyst/ScriptRunner.pm line 50
> >        Catalyst::ScriptRunner::run('Catalyst::ScriptRunner', 'Waste::Web', 'Server') called at script/waste_web_server.pl line 8
> > Debugged program terminated.  Use q to quit or R to restart,
> >  use o inhibit_exit to avoid stopping after program termination,
> >  h q, h R or h o to get additional info.
> >
> >
> > _______________________________________________
> > List: Catalyst at lists.scsys.co.uk
> > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> > Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> > Dev site: http://dev.catalyst.perl.org/
> 
> 
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
> 
> 
> 
> -- 
>  Will Trillich :: 812.454.6431
> 
> “Grading takes away all the fun from failing. And a huge part of education is about failure.”  -- Shimon Schocken
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/




More information about the Catalyst mailing list