# Yaml error. dunno why

**URL:** <https://rubytalk.org/t/yaml-error-dunno-why/42071>\
**Category:** ruby-talk\
**Created:** [10 November 2007 13:55 UTC](https://rubytalk.org/t/yaml-error-dunno-why/42071 "2007-11-10T13:55:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junkone](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@Junkone](https://rubytalk.org/u/Junkone)\
**Post date:** [10 November 2007 13:55 UTC](https://rubytalk.org/t/yaml-error-dunno-why/42071/1 "2007-11-10T13:55:06Z")

</div>

i have a simple yml file and am trying to parse it.

development:  
&nbsp;&nbsp;&nbsp;&nbsp;TWSDirectory: E:\Jts\dlqkjifys\  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Second: E:\Jts\test\

i get a error that i am not able to comprehend. pl help  
irb(main):020:0\> conf = YAML::load(File.open(RailsDirectory+ 'config/  
constants.y  
ml'))  
'rgumentError: syntax error on line 5, col 12: ` Second: E:\Jts  
\test\  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):20

---

<div class="post-metadata">

**Author:** ![Michael\_Guterl1](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@Michael\_Guterl1](https://rubytalk.org/u/Michael_Guterl1)\
**Post date:** [10 November 2007 14:03 UTC](https://rubytalk.org/t/yaml-error-dunno-why/42071/2 "2007-11-10T14:03:49Z")

</div>

> i have a simple yml file and am trying to parse it.
> 
> development:  
> &nbsp;&nbsp;&nbsp;TWSDirectory: E:\Jts\dlqkjifys\  
> &nbsp;&nbsp;&nbsp;&nbsp;Second: E:\Jts\test\
> 
> i get a error that i am not able to comprehend. pl help  
> irb(main):020:0\> conf = YAML::load(File.open(RailsDirectory+ 'config/  
> constants.y  
> ml'))  
> 'rgumentError: syntax error on line 5, col 12: ` Second: E:\Jts  
> \test\  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):20

> **···**
>
> On Nov 10, 2007 8:55 AM, Junkone \<junkone1@gmail.com\> wrote:  
> ---  
> development:  
> &nbsp;&nbsp;TWSDirectory: E:\Jts\dlqkjifys\  
> &nbsp;&nbsp;Second: E:\Jts\test\
> 
> I believe that --- is important, but I'm not sure. Try building your hash  
> in irb and YAML.dump it.
> 
> Michael Guterl

---

<div class="post-metadata">

**Author:** ![Joel\_VanderWerf1](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Joel\_VanderWerf1](https://rubytalk.org/u/Joel_VanderWerf1)\
**Post date:** [10 November 2007 20:33 UTC](https://rubytalk.org/t/yaml-error-dunno-why/42071/3 "2007-11-10T20:33:05Z")

</div>

Junkone wrote:

> i have a simple yml file and am trying to parse it.
> 
> development:  
> &nbsp;&nbsp;&nbsp;&nbsp;TWSDirectory: E:\Jts\dlqkjifys\  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Second: E:\Jts\test\
> 
> i get a error that i am not able to comprehend. pl help  
> irb(main):020:0\> conf = YAML::load(File.open(RailsDirectory+ 'config/  
> constants.y  
> ml'))  
> 'rgumentError: syntax error on line 5, col 12: ` Second: E:\Jts  
> \test\  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):20

I suspect the backslashes need to be escaped:

h = YAML.load(\<\<END)  
development:  
&nbsp;&nbsp;&nbsp;TWSDirectory: E:\\Jts\\dlqkjifys\\  
&nbsp;&nbsp;&nbsp;Second: E:\\Jts\\test\\  
END

puts h.to\_yaml

\_\_END\_\_

Output:

> **···**
>
> ---  
> development:  
> &nbsp;&nbsp;&nbsp;TWSDirectory: E:\Jts\dlqkjifys\  
> &nbsp;&nbsp;&nbsp;Second: E:\Jts\test\
> 
> --  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

---

<div class="post-metadata">

**Author:** ![Arlen\_Christian\_Mar1](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@Arlen\_Christian\_Mar1](https://rubytalk.org/u/Arlen_Christian_Mar1)\
**Post date:** [10 November 2007 21:34 UTC](https://rubytalk.org/t/yaml-error-dunno-why/42071/4 "2007-11-10T21:34:14Z")

</div>

Hi,

> i have a simple yml file and am trying to parse it.
> 
> development:  
> &nbsp;&nbsp;&nbsp;&nbsp;TWSDirectory: E:\Jts\dlqkjifys\  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Second: E:\Jts\test\

First, make sure your items are indented at the same level:

development:  
&nbsp;&nbsp;&nbsp;&nbsp;TWSDirectory: E:\Jts\dlqkjifys\  
&nbsp;&nbsp;&nbsp;&nbsp;Second: E:\Jts\test\

Notice the way "TWSDirectory" and "Second" have the same number of  
spaces before them.

This may still not work. Have a look at this example:

irb(main):008:0\> YAML.load \<\<-YAML  
irb(main):009:0" abcdefg\  
irb(main):010:0" hijkl  
irb(main):011:0" YAML  
=\> "abcdefghijkl"

Your "\" at the end of the line is joining the two lines into one!  
Suffice to say, this works:

irb(main):017:0\> YAML.load \<\<YAML  
irb(main):018:0" development:  
irb(main):019:0" TWSDirectory: E:\Jts\dlqkjifys  
irb(main):020:0" Second: E:\Jts\test  
irb(main):021:0" YAML  
=\> {"development"=\>{"TWSDirectory"=\>"E:Jtsdlqkjifys", "Second"=\>"E:Jts  
\test"}}  
irb(main):022:0\>

> i get a error that i am not able to comprehend. pl help  
> irb(main):020:0\> conf = YAML::load(File.open(RailsDirectory+ 'config/  
> constants.y  
> ml'))  
> 'rgumentError: syntax error on line 5, col 12: ` Second: E:\Jts  
> \test\  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from e:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):20

Hope this helps,

Arlen

> **···**
>
> On Sat, 2007-11-10 at 22:55 +0900, Junkone wrote:
