Problems loading an app
Hello, Since I moved to the "load_app 'whatever';" scheme I've found that not all the errors are reported in the same way. When you try to run the application, sometimes you only get: unable to load application whatever at ../local/Dancer.pm line 155. I don't know if I'm doing something wrong, but it depends on the error: Example: missing a ; Bareword found where operator expected at path/lib/whatever.pm line 64, near "redirect" (Missing semicolon on previous line?) unable to load application whatever at ../local/Dancer.pm line 155. BUT, something like ($w doesn't exist): print "uh" if $user =~ m/$w/; Shows only the 'unable to load' message, but with "use whatever.pm" you get a more verbose message: Global symbol "$w" requires explicit package name at path/lib/whatever.pm line 62. Compilation failed in require at ./whatever.pl line 7. BEGIN failed--compilation aborted at ./whatever.pl line 7. Regards, Juanjo -- jjm's home: http://www.usebox.net/jjm/ blackshell: http://blackshell.usebox.net/ ramble on: http://rambleon.usebox.net/
2010/4/24 Juan J. <reidrac@usebox.net>
Hello,
Since I moved to the "load_app 'whatever';" scheme I've found that not all the errors are reported in the same way.
Could you show us some code? It would be very difficult in deciphering the problem without seeing any. I suspect you're not using a semicolon at the end of "get" or "put" or "any" statements. get "/some/path" { }; # <-- semicolon
El sáb, 24-04-2010 a las 23:08 +0300, sawyer x escribió:
[...]
Could you show us some code? It would be very difficult in deciphering the problem without seeing any.
I suspect you're not using a semicolon at the end of "get" or "put" or "any" statements. get "/some/path" { }; # <-- semicolon
That's not the problem. I already showed you two examples. Let me try it again :) Following code: get '/' => sub { print "this is an error" print "whatever"; }; Has the same error report using "use" and "load_app" in app.pl. Following code: get '/' => sub { my $test = 'something'; print "test" if $something =~ m/$x/; }; Has different error reports using "use" and "load_app" in app.pl, and the error reported with "load_app" it's too much terse to find the problem, just: unable to load application whatever at ../local/Dancer.pm line 155. Regards, Juanjo -- jjm's home: http://www.usebox.net/jjm/ blackshell: http://blackshell.usebox.net/ ramble on: http://rambleon.usebox.net/
El sáb, 24-04-2010 a las 21:15 +0100, Juan J. Martínez escribió:
[...] I already showed you two examples. Let me try it again :)
At least I tried, excuse my English :( --- CUT test.pm --- package test; use Dancer ':syntax'; our $VERSION = '0.1'; get '/' => sub { my $w = "whatever"; print "test" if $w =~ m/$fail/; template 'index'; }; true; --- CUT --- Case 1: --- CUT test.pl --- #!/usr/bin/perl use Dancer; load_app 'test'; dance; --- CUT --- Error reported: unable to load application test at ../local/Dancer.pm line 155. Case 2: --- CUT test.pl --- #!/usr/bin/perl use Dancer; use test; dance; --- CUT --- Error reported: Global symbol "$fail" requires explicit package name at /home/reidrac/src/dancer/test/lib/test.pm line 9. Compilation failed in require at ./test.pl line 4. BEGIN failed--compilation aborted at ./test.pl line 4. ** I was complaining about case 1, because I guess the error report should be as verbose as case 2. Regards, Juanjo -- jjm's home: http://www.usebox.net/jjm/ blackshell: http://blackshell.usebox.net/ ramble on: http://rambleon.usebox.net/
Hello, Any comment on this? Should I file a bug report? Yesterday night I misstyped "params->{user}" as "param->{user}" and almost got crazy looking for the problem because the error message is too terse (just "unable to load application..."). Regards, Juanjo -- jjm's home: http://www.usebox.net/jjm/ blackshell: http://blackshell.usebox.net/ ramble on: http://rambleon.usebox.net/
2010/4/27 Juan J. <reidrac@usebox.net>
Hello,
Hi, Any comment on this? Should I file a bug report?
Sorry for the late reply, I've personally been a bit busy and I reckon so where a few other people on the list. I've gone over your code. There are two issues: 1. Instead of 'load_app("test")', you should write 'use load;'. That would fix the first issue. 2. You accidentally used a variable "$fail" when you haven't declared it yet. Here is a working version: # ---- test.pl ---- /usr/bin/perl use Dancer; use test; dance; # ---- test.pm ---- package test; use Dancer ':syntax'; our $VERSION = '0.1'; get '/' => sub { my $w = "whatever"; my $fail = "nothing"; print "test" if $w =~ m/$fail/; template 'index'; }; true; # ---- ---- Happy dancing, :) Sawyer.
El mar, 27-04-2010 a las 23:56 +0300, sawyer x escribió:
[...]
Sorry for the late reply, I've personally been a bit busy and I reckon so where a few other people on the list.
No need to apology, thank you :)
I've gone over your code. There are two issues:
1. Instead of 'load_app("test")', you should write 'use load;'. That would fix the first issue.
I don't understand what do you mean with "use load". $ dancer -a whatever + ./whatever + whatever/app.psgi + whatever/whatever.pl ...etc... $ cat whatever/whatever.pl #!/usr/bin/perl use Dancer; load_app 'whatever'; dance; I'm trying to explain that the load_app has a side effect in the way Perl report some bugs, making the report useless.
2. You accidentally used a variable "$fail" when you haven't declared it yet. Here is a working version:
Yes, that's to force the error that, it's differently reported by Perl when dancer loads my app with "use whatever;" than when using "load_app('whatever')". Regards, Juanjo -- jjm's home: http://www.usebox.net/jjm/ blackshell: http://blackshell.usebox.net/ ramble on: http://rambleon.usebox.net/
2010/4/28 Juan J. <reidrac@usebox.net>
I've gone over your code. There are two issues:
1. Instead of 'load_app("test")', you should write 'use load;'. That would fix the first issue.
Sorry, I meant "use test;", which will in turn load the code in "test.pm". I'm more tired than I thought. :) Sawyer.
On Tuesday 27 April 2010 21:56:18 sawyer x wrote:
Sorry for the late reply, I've personally been a bit busy and I reckon so where a few other people on the list.
Indeed :)
I've gone over your code. There are two issues:
1. Instead of 'load_app("test")', you should write 'use load;'. That would fix the first issue.
I assume you mean "use test;" to be equivalent, just in case anyone thinks 'load' is some voodoo module that should be loaded :) Either way, the scaffolding script in the devel branch writes out the app.pl file using load_app, so that method should work cleanly without problems - looks like we may have something to fix here.
2. You accidentally used a variable "$fail" when you haven't declared it yet. Here is a working version:
I think that was the idea of the example, to demonstrate a simple, easy, silly mistake which should be reported clearly by Perl, but apparently results instead in a simple "unable to load application" message, with the true error message swallowed :) On Tuesday 27 April 2010 19:46:13 Juan J. Martínez wrote:
Any comment on this? Should I file a bug report?
Yes, if you don't mind, go ahead and raise it at http://github.com/sukria/Dancer/issues - one of us can then investigate in detail as soon as possible. Thanks! -- David Precious <davidp@preshweb.co.uk> http://blog.preshweb.co.uk/ www.preshweb.co.uk/twitter www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook www.preshweb.co.uk/identica www.lyricsbadger.co.uk "Programming is like sex. One mistake and you have to support it for the rest of your life". (Michael Sinz)
El mar, 27-04-2010 a las 22:18 +0100, David Precious escribió:
[...] On Tuesday 27 April 2010 19:46:13 Juan J. Martínez wrote:
Any comment on this? Should I file a bug report?
Yes, if you don't mind, go ahead and raise it at http://github.com/sukria/Dancer/issues - one of us can then investigate in detail as soon as possible.
Done: http://github.com/sukria/Dancer/issues/issue/66 Thanks for you help! Cheers, Juanjo -- jjm's home: http://www.usebox.net/jjm/ blackshell: http://blackshell.usebox.net/ ramble on: http://rambleon.usebox.net/
On Tuesday 27 April 2010 22:28:30 Juan J. Martínez wrote:
El mar, 27-04-2010 a las 22:18 +0100, David Precious escribió:
[...]
On Tuesday 27 April 2010 19:46:13 Juan J. Martínez wrote:
Any comment on this? Should I file a bug report?
Yes, if you don't mind, go ahead and raise it at http://github.com/sukria/Dancer/issues - one of us can then investigate in detail as soon as possible.
Nice one, thank you :) Can you confirm if you have an up-to-date copy of the devel branch of Dancer (I'm assuming that's what you're using, as opposed to a release version)? Looking in lib/Dancer.pm, I see that it attempts to propagate any errors: 163 # we want to propagate loading errors, so don't use ModuleLoader here 164 eval "use $app"; 165 die "unable to load application $app : $@" if $@; -- David Precious <davidp@preshweb.co.uk> http://blog.preshweb.co.uk/ www.preshweb.co.uk/twitter www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook www.preshweb.co.uk/identica www.lyricsbadger.co.uk "Programming is like sex. One mistake and you have to support it for the rest of your life". (Michael Sinz)
El mar, 27-04-2010 a las 22:36 +0100, David Precious escribió:
[...] Can you confirm if you have an up-to-date copy of the devel branch of Dancer (I'm assuming that's what you're using, as opposed to a release version)?
Looking in lib/Dancer.pm, I see that it attempts to propagate any errors:
163 # we want to propagate loading errors, so don't use ModuleLoader here 164 eval "use $app"; 165 die "unable to load application $app : $@" if $@;
Oh my, after all this noise I've noticed I wasn't tracking Devel properly and I was missing (among others) the commit that actually fixed that. Thank you again. Cheers, Juanjo -- jjm's home: http://www.usebox.net/jjm/ blackshell: http://blackshell.usebox.net/ ramble on: http://rambleon.usebox.net/
participants (3)
-
David Precious -
Juan J. Martínez -
sawyer x