# YAML Library not recognized

**URL:** <https://www.ruby-forum.com/t/yaml-library-not-recognized/114441>\
**Category:** Ruby\
**Created:** [September 12, 2007, 6:43pm UTC](https://www.ruby-forum.com/t/yaml-library-not-recognized/114441 "2007-09-12T18:43:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![simianstyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@simianstyle](https://www.ruby-forum.com/u/simianstyle)\
**Post date:** [September 12, 2007, 6:43pm UTC](https://www.ruby-forum.com/t/yaml-library-not-recognized/114441/1 "2007-09-12T18:43:15Z")

</div>

My setup:  
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]

So i compiled ruby from source and installed it on my system (ubuntu  
7.04), and was happy for a while. However i fired up irb one day and ran  
the following command:

{}.to\_yaml

and i got the following error:

NoMethodError: undefined method `to\_yaml’ for {}:Hash

I then installed the yaml library from the synaptic package manager for  
ruby, and restarted my system. I still keep getting the same error.

My hypothesis as to why this is happening is because when I compiled  
ruby, i added the “prefix=/usr/local” flag when i ran the config file,  
so it was installed to a different directory other than what synaptic  
would usually install it to. However, it still doesn’t recognize the  
YAML library.

I can’t seem to figure out why there is no YAML library on my version of  
Ruby or how to install it. If anybody can help me out with this problem,  
i’d really appreciated it.

---

<div class="post-metadata">

**Author:** ![simianstyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@simianstyle](https://www.ruby-forum.com/u/simianstyle)\
**Post date:** [September 12, 2007, 7:17pm UTC](https://www.ruby-forum.com/t/yaml-library-not-recognized/114441/2 "2007-09-12T19:17:39Z")

</div>

Dnia Thu, 13 Sep 2007 01:43:21 +0900  
Ahmed H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) napisaÅ‚(a):

> {}.to\_yaml
> 
> and i got the following error:
> 
> NoMethodError: undefined method `to\_yaml’ for {}:Hash

irb(main):001:0\> {}.to\_yaml  
NoMethodError: undefined method `to\_yaml’ for {}:Hash  
from (irb):1  
irb(main):002:0\> require ‘yaml’  
=\> true  
irb(main):003:0\> {}.to\_yaml  
=\> “— {}\n\n”

It works on my system (Ubuntu 7.04, Ruby from package).

---

<div class="post-metadata">

**Author:** ![simianstyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@simianstyle](https://www.ruby-forum.com/u/simianstyle)\
**Post date:** [September 12, 2007, 9:48pm UTC](https://www.ruby-forum.com/t/yaml-library-not-recognized/114441/3 "2007-09-12T21:48:14Z")

</div>

Hi Ahmed 🙂 and everyone

Is there some kind of a config option that will auto require yaml lib?  
On windows  
{}.to\_yaml works without requiring yaml in irb

Many thanks  
Eugene.
