puzzled by yaml error ..

Discussion in 'Ruby' started by Jedrin, Jul 21, 2011.

  1. Jedrin

    Jedrin Guest

    I have some code that uses a yaml file. I moved the code onto a
    different server in windows server 2008 or some such.

    My code seems to fail here on the other machine:

    label_path = File.dirname(__FILE__) + '/' + cfg[:label_config]

    dbg 'load ' + label_path

    @full_cfg = YAML::load( File.open(label_path))


    load C:/inetpub/wwwroot/Larry/labels.yml
    C:/Ruby192/lib/ruby/1.9.1/psych.rb:148:in `parse': couldn't parse YAML
    at line 5
    column 7 (Psych::SyntaxError)
    from C:/Ruby192/lib/ruby/1.9.1/psych.rb:148:in `parse_stream'
    from C:/Ruby192/lib/ruby/1.9.1/psych.rb:119:in `parse'
    from C:/Ruby192/lib/ruby/1.9.1/psych.rb:106:in `load'
    from C:/inetpub/wwwroot/Larry/parse-lib.rb:419:in `configure'
    from C:/inetpub/wwwroot/Larry/parse-documents.rb:55:in `block
    in parse'
    from C:/inetpub/wwwroot/Larry/parse-documents.rb:48:in `each'
    from C:/inetpub/wwwroot/Larry/parse-documents.rb:48:in `parse'
    from univ-parse.rb:33:in `<main>'

    --------------------------

    so I wrote test program to try to open the same file with yaml:

    But this program works fine on the same file on the machine that has
    the problem and when I do that, the error does not occur. The error
    doesn't happen when I run it on my lap top either regardless of which
    program I use. What can I try ? my laptop is ruby 1.9.2p136, the other
    machine is 1.9.2.p180


    require 'yaml'

    cfg_file = ARGV[0]
    puts 'open ' + cfg_file
    @raw_cfg = YAML::load( File.open(cfg_file))

    p @raw_cfg

    ---------------

    C:\inetpub\wwwroot\Larry>ruby yml-test.rb labels.yml
    open labels.yml
    {"product"=>{"start_label"=>["\\d\\.\\s*product and company identi ..
    ...
    ...








    C:\inetpub\wwwroot\Larry>ruby yml-test.rb labels.yml
    open labels.yml
     
    Jedrin, Jul 21, 2011
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.