config.yml YAML tabs vs spaces
Hello , I just started to use Dancer::Plugins::Database and spent some time trying yo figure out why the config from the manual doesn't work for me . The problem ( or a feature ) that YAML doesn't treat tabs as whitespace , and I was getting the following croaks : perl bin/q.pl Unable to parse the configuration file: /home/toor/dancer/MyWeb-App/config.yml: Died at /usr/share/perl5/YAML/Loader.pm line 674, <$IN> line 1. at /usr/share/perl5/Dancer/Config.pm line 204 Dancer::Config::load_settings_from_yaml('/home/toor/dancer/MyWeb-App/config.yml') called at /usr/share/perl5/Dancer/Config.pm line 181 Dancer::Config::load('Dancer::Config') called at /usr/share/perl5/Dancer.pm line 212 Dancer::import('Dancer') called at bin/q.pl line 1 main::BEGIN() called at /usr/share/perl5/Dancer.pm line 1 eval {...} called at /usr/share/perl5/Dancer.pm line 1 BEGIN failed--compilation aborted at bin/q.pl line 1. using spaces solved the problem . So I think that it will be not bad to mention somewhere in the documentation that tabs shouldn't be used in config.yml . Thank you , Alex
On Thu, Nov 10, 2011 at 02:39:14PM +0100, Alex Mestiashvili wrote:
using spaces solved the problem . So I think that it will be not bad to mention somewhere in the documentation that tabs shouldn't be used in config.yml .
On the other hand, the fact that config.yml is a YAML file implies that it must have correct YAML syntax. See http://www.yaml.org/spec/1.2/spec.html#space/indentation/ -- Philippe Bruhat (BooK) No one profits at the death of another (except for the mortician). (Moral from Groo The Wanderer #7 (Epic))
On 11/10/2011 04:53 PM, Philippe Bruhat (BooK) wrote:
On Thu, Nov 10, 2011 at 02:39:14PM +0100, Alex Mestiashvili wrote:
using spaces solved the problem . So I think that it will be not bad to mention somewhere in the documentation that tabs shouldn't be used in config.yml .
On the other hand, the fact that config.yml is a YAML file implies that it must have correct YAML syntax.
See http://www.yaml.org/spec/1.2/spec.html#space/indentation/
Phew, that is a lot of stuff for micro web framework supposed to be really easy ... I mean, I can live with YAML - but it's not fun and in this area we didn't get a choice yet. Regards Racke -- LinuXia Systems => http://www.linuxia.de/ Expert Interchange Consulting and System Administration ICDEVGROUP => http://www.icdevgroup.org/ Interchange Development Team
On Thu, Nov 10, 2011 at 6:00 PM, Stefan Hornburg (Racke) <racke@linuxia.de>wrote:
On 11/10/2011 04:53 PM, Philippe Bruhat (BooK) wrote:
Phew, that is a lot of stuff for micro web framework supposed to be really easy ...
That isn't really fair to say, Stefan. Configuration (as with many things that sound simple) is annoying and difficult. Each configuration format has it's major downsides and it's definitely not up to us to come up with something special. In fact, if we tried to introduce a new format it would probably make more of a mess. What we can do is try to take a format that is reasonably easy to read, easy to edit (JSON and XML are out), easy to understand multi-levels (that throws INI and Apache-style out the window) and has a good module support so we don't have to implement a new parser. Dancer *is* really easy, and we tried to choose the easiest configuration format we could. I think we made a good decision. I'm sorry that format has downsides, but it doesn't mean we messed up, because any format will have some major downside. I believe that in Dancer 2.0 we could abstract this away and you could have various engines for configuration reading. Still, this is a *very* small point to hold on to in the great scheme of things. I believe there are much better things to put our efforts (and patience) in. Have a great day, S.
On 11/10/2011 04:53 PM, Philippe Bruhat (BooK) wrote:
On Thu, Nov 10, 2011 at 02:39:14PM +0100, Alex Mestiashvili wrote:
using spaces solved the problem . So I think that it will be not bad to mention somewhere in the documentation that tabs shouldn't be used in config.yml .
On the other hand, the fact that config.yml is a YAML file implies that it must have correct YAML syntax.
See http://www.yaml.org/spec/1.2/spec.html#space/indentation/
I agree and after all I learned something new, but Dancer positions itself like "Dead Simple" and imho it won't hurt to have a line stating that config.yml should use YAML syntax . Such obvious fact that .yml means man YAML wasn't clear for me . Best regards , Alex
Alex Mestiashvili wrote, On 11/10/11 11:47:
On 11/10/2011 04:53 PM, Philippe Bruhat (BooK) wrote:
On Thu, Nov 10, 2011 at 02:39:14PM +0100, Alex Mestiashvili wrote:
using spaces solved the problem . So I think that it will be not bad to mention somewhere in the documentation that tabs shouldn't be used in config.yml .
I agree and after all I learned something new, but Dancer positions itself like "Dead Simple" and imho it won't hurt to have a line stating that config.yml should use YAML syntax . Such obvious fact that .yml means man YAML wasn't clear for me .
I couldn't agree more. The YAML-related Dancer error message is anything but "dead simple" (it is very perlish-wise informative, though). It took me a long time to understand what's wrong, way too much time compare to the minor offense of a single tab. Here's the error I get in current Dancer due to Tab in "config.yml": ==== Use of uninitialized value in subtraction (-) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 726, <$IN> line 1. Use of uninitialized value in numeric eq (==) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 361, <$IN> line 1. Use of uninitialized value in numeric eq (==) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 361, <$IN> line 1. Use of uninitialized value in numeric eq (==) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 361, <$IN> line 1. Use of uninitialized value in substitution (s///) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 331, <$IN> line 1. Use of uninitialized value in substitution (s///) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 338, <$IN> line 1. Use of uninitialized value in substitution (s///) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 342, <$IN> line 1. Use of uninitialized value in substitution (s///) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 407, <$IN> line 1. Use of uninitialized value in substitution (s///) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 407, <$IN> line 1. Unable to parse the configuration file: /home/gordon/projects/perl_dancer_test/badyaml/config.yml: YAML Error: Invalid element in map Code: YAML_LOAD_ERR_BAD_MAP_ELEMENT Line: 27 Document: 1 at /usr/local/share/perl/5.12.4/YAML.pm line 36 at /usr/local/share/perl/5.12.4/Dancer/Config.pm line 204 Dancer::Config::load_settings_from_yaml('/home/gordon/projects/perl_dancer_test/badyaml/config.yml') called at /usr/local/share/perl/5.12.4/Dancer/Config.pm line 181 Dancer::Config::load('Dancer::Config') called at /usr/local/share/perl/5.12.4/Dancer.pm line 230 Dancer::import('Dancer') called at ./bin/app.pl line 2 main::BEGIN() called at /usr/local/share/perl/5.12.4/Dancer.pm line 2 eval {...} called at /usr/local/share/perl/5.12.4/Dancer.pm line 2 BEGIN failed--compilation aborted at ./bin/app.pl line 2. ==== As a Dancer newbie, it takes some time to find the only relevant message in the middle of this mess: "unable to parse the configuration file". Perhaps something like this minor change would be friendlier ? https://github.com/agordon/Dancer/commit/f3aea9d810b9f08d34946a1acc657e78686... The error message would then become: ===== Use of uninitialized value in subtraction (-) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 726, <$IN> line 1. Use of uninitialized value in numeric eq (==) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 361, <$IN> line 1. Use of uninitialized value in numeric eq (==) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 361, <$IN> line 1. Use of uninitialized value in numeric eq (==) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 361, <$IN> line 1. Use of uninitialized value in substitution (s///) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 331, <$IN> line 1. Use of uninitialized value in substitution (s///) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 338, <$IN> line 1. Use of uninitialized value in substitution (s///) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 342, <$IN> line 1. Use of uninitialized value in substitution (s///) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 407, <$IN> line 1. Use of uninitialized value in substitution (s///) at /usr/local/share/perl/5.12.4/YAML/Loader.pm line 407, <$IN> line 1. YAML Error: Invalid element in map Code: YAML_LOAD_ERR_BAD_MAP_ELEMENT Line: 27 Document: 1 at /usr/local/share/perl/5.12.4/YAML.pm line 36 Error in configuration file: /home/gordon/projects/perl_dancer_test/badyaml/config.yml Please ensure it is a valid YAML file. BEGIN failed--compilation aborted at ./bin/app.pl line 2. ===== It's still too verbose (couldn't find a way to disable YAML's warnings, and the "BEGIN failed" is there to stay) - but at least it's easier to read. -gordon
On 11/10/2011 07:04 PM, Assaf Gordon wrote:
Alex Mestiashvili wrote, On 11/10/11 11:47:
On 11/10/2011 04:53 PM, Philippe Bruhat (BooK) wrote:
On Thu, Nov 10, 2011 at 02:39:14PM +0100, Alex Mestiashvili wrote:
using spaces solved the problem . So I think that it will be not bad to mention somewhere in the documentation that tabs shouldn't be used in config.yml .
I agree and after all I learned something new, but Dancer positions itself like "Dead Simple" and imho it won't hurt to have a line stating that config.yml should use YAML syntax . Such obvious fact that .yml means man YAML wasn't clear for me .
I couldn't agree more.
The YAML-related Dancer error message is anything but "dead simple" (it is very perlish-wise informative, though). It took me a long time to understand what's wrong, way too much time compare to the minor offense of a single tab.
Same goes for missing final newline. Regards Racke -- LinuXia Systems => http://www.linuxia.de/ Expert Interchange Consulting and System Administration ICDEVGROUP => http://www.icdevgroup.org/ Interchange Development Team
Well, aren't we trying to overkill things there? Dancer is a web application framework, it may have downsides, but clearly, if there is something to say about it, it's that it's dead-simple to use. If you feed it with an invalid YAML file, well, the parsing will fail, and the error message will come directly from the parser, not from Dancer itself. Many options already exist to avoid this: - you can set your settings in a perl script included in your app (using 'set'). - you can bootstrap an application with "dancer -a" and you'll get a working config.yml file - if you build a config.yml file by hand, you're supposed to know at least how to do it, so maybe experimenting with YAML first could be a good idea I don't think Dancer should do more than that regarding YAML files... 2011/11/10 Stefan Hornburg (Racke) <racke@linuxia.de>:
On 11/10/2011 07:04 PM, Assaf Gordon wrote:
Alex Mestiashvili wrote, On 11/10/11 11:47:
On 11/10/2011 04:53 PM, Philippe Bruhat (BooK) wrote:
On Thu, Nov 10, 2011 at 02:39:14PM +0100, Alex Mestiashvili wrote:
using spaces solved the problem . So I think that it will be not bad to mention somewhere in the documentation that tabs shouldn't be used in config.yml .
I agree and after all I learned something new, but Dancer positions itself like "Dead Simple" and imho it won't hurt to have a line stating that config.yml should use YAML syntax . Such obvious fact that .yml means man YAML wasn't clear for me .
I couldn't agree more.
The YAML-related Dancer error message is anything but "dead simple" (it is very perlish-wise informative, though). It took me a long time to understand what's wrong, way too much time compare to the minor offense of a single tab.
Same goes for missing final newline.
Regards Racke
-- LinuXia Systems => http://www.linuxia.de/ Expert Interchange Consulting and System Administration ICDEVGROUP => http://www.icdevgroup.org/ Interchange Development Team
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
On Thu, Nov 10, 2011 at 6:47 PM, Alex Mestiashvili < alex@biotec.tu-dresden.de> wrote:
Such obvious fact that .yml means man YAML wasn't clear for me .
I'm sorry. While I think it's perfectly alright to add comments for stuff like "you can uncomment the next line to add support for Template Toolkit" (which we did), I do not intend to add a line to a .yml file saying "This is a YAML file". It's just... silly. It would be like adding a line to .ini file saying "this is an INI file" or to a .jsn file saying "This is a JSON file". The syntax is clear, YAML is well known and understood (especially in the Perl community) and while I'm sorry you didn't realize in first glance that it was a YAML file, I believe it's still very clear and I don't intend on adding this line on this basis alone. However, if you get enough core developers to agree to it, I'll add it. I hope that other than that, you're getting a good experience out of Dancer. All the best, S.
On 11/13/2011 05:28 PM, sawyer x wrote:
On Thu, Nov 10, 2011 at 6:47 PM, Alex Mestiashvili <alex@biotec.tu-dresden.de <mailto:alex@biotec.tu-dresden.de>> wrote:
Such obvious fact that .yml means man YAML wasn't clear for me .
I'm sorry. While I think it's perfectly alright to add comments for stuff like "you can uncomment the next line to add support for Template Toolkit" (which we did), I do not intend to add a line to a .yml file saying "This is a YAML file". It's just... silly. It would be like adding a line to .ini file saying "this is an INI file" or to a .jsn file saying "This is a JSON file".
The syntax is clear, YAML is well known and understood (especially in the Perl community) and while I'm sorry you didn't realize in first glance that it was a YAML file, I believe it's still very clear and I don't intend on adding this line on this basis alone. However, if you get enough core developers to agree to it, I'll add it.
I hope that other than that, you're getting a good experience out of Dancer.
All the best, S.
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Thank you for such a nice framework , I really enjoy it . There is nothing to be sorry for ,I totally understand your position and agree with it . Best regards , Alex
participants (6)
-
Alex Mestiashvili -
Alexis Sukrieh -
Assaf Gordon -
Philippe Bruhat (BooK) -
sawyer x -
Stefan Hornburg (Racke)