Cannot start Dancer2 when Dancer2::Plugin has Moo attribute
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Reproduce the failure with app.psgi and the simplified Dancer2::Plugin::App example, using the plackup command shown. Start with the Dancer2::Plugin loading path and the lib/App.pm stack-trace location, then verify that an attribute-bearing plugin can load and the example application starts without the Type::Tiny error.
Written by the indexing model from the issue text.
Description
Since 2.1.0 Dancer2 cannot be started anymore,
when one of the Dancer2 plugins has a Moo attribute. It crashes with the following error:
$ plackup app.psgi
Error while loading /Users/njfranck/git/dancer2-plugin-issue/app.psgi: Can't locate object method "_p2_has" via package "Type::Tiny" at (eval 404) line 23.
Compilation failed in require at lib/App.pm line 6.
BEGIN failed--compilation aborted at lib/App.pm line 6.
Compilation failed in require at /Users/njfranck/git/dancer2-plugin-issue/app.psgi line 6.
BEGIN failed--compilation aborted at /Users/njfranck/git/dancer2-plugin-issue/app.psgi line 6.
These are my source files (simplified for testing reasons):
Dancer2::Plugin::App:
package Dancer2::Plugin::App;
use strict;
use warnings;
use Dancer2::Plugin;
has user_id => (
is => 'ro',
default => sub {"nicolas"},
);
sub current_user {
$_[0]->dsl->var("user");
}
sub load_current_user {
$_[0]->dsl->var(user => {id => "test"});
}
plugin_keywords(qw(
current_user
load_current_user
));
1;
App:
package App;
use strict;
use warnings;
use Dancer2;
use Dancer2::Plugin::App;
hook before => sub {
load_current_user();
};
get '/' => sub {
content_type 'text/plain';
my $current_user = current_user();
sprintf("Dancer2::VERSION=%s", $Dancer2::VERSION);
};
1;
app.psgi:
#/usr/bin/env perl
use strict;
use warnings;
use lib qw(lib);
use App;
App->to_app;
According to the documentation using Dancer2::Plugin turns
your package into a Moo package, right?
- Dominant language
- Perl
- Stars
- 604
- Forks
- 287
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 6
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PerlDancer/Dancer2
-
Add .gitattributes so share/skel keeps LF on a Windows git checkoutPossibly taken @sadhana-s-codez claimed this 2 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
PerlDancer/Dancer2#1854 · 1 comment ·
Maintainers usually reply within 1 day
-
dancer2 gen -c writes the Dockerfile outside the app directoryPossibly taken @sjh9714 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
PerlDancer/Dancer2#1851 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
PerlDancer/Dancer2#1850 ·
Maintainers usually reply within 1 day
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
PerlDancer/Dancer2#1820 ·
Maintainers usually reply within 1 day
-
Enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
PerlDancer/Dancer2#1819 ·
Maintainers usually reply within 1 day
All issues in PerlDancer/Dancer2
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
jimsalterjrs/sanoid#1116 · 1 reaction ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
major/MySQLTuner-perl#1007 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
bioconda/bioconda-recipes#70187 ·
Maintainers usually reply within 2 days