views:

28

answers:

1

I have installed yajl, libyajl-dev, and the yajl-ruby gem on a ubuntu 10.04 installation.

I added the gem to a 2.3.8 ruby on rails installation since the release notes for 2.3.6 indicated that yajl would be used if present in the system. Rails bails with an error message along the lines of 'unable to load yajl-ruby' so I thought I would see what is happening in an irb session. This is what happens:

$ dpkg -l | grep yajl
ii  libyajl-dev                       1.0.8-1                                         Yet Another JSON Library - development files
ii  libyajl1                          1.0.8-1                                         Yet Another JSON Library
ii  yajl-tools                        1.0.8-1                                         Yet Another JSON Library - tools
$ gem list | grep yajl
yajl-ruby (0.7.6)
$ irb 
> require 'yajl'
LoadError: no such file to load -- yajl
        from (irb):1:in `require'
        from (irb):1
        from :0
> require 'yajl/gzip'
LoadError: no such file to load -- yajl/gzip
        from (irb):2:in `require'
        from (irb):2
        from :0
> require 'yajl-ruby'
LoadError: no such file to load -- yajl-ruby
        from (irb):3:in `require'
        from (irb):3
        from :0

I cannot find anyone else with this problem after spending a while searching for this issue. Anyone have any idea what is going on?

A: 

Use the gem instead sudo gem install yajl-ruby

Then just use it like any other gem in your ruby script

require 'rubygems'
require 'yajl'

json = File.new('test.json', 'r')
parser = Yajl::Parser.new
hash = parser.parse(json)
Warren Noronha
I figured it out myself after a bit of hacking and remembering the requirement of rubygems. I am a ruby n00b and have primarily written ruby for scripts without gems and ruby which already has rubygems loaded for a project.Thanks you. Correct and succinct.
Aaron Brashears