2

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?

1 Answer 1

2

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)
2
  • 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. Jul 12, 2010 at 5:18
  • I stumbled upon a similar problem, the messages was /usr/lib/ruby/vendor_ruby/yajl.rb:2:in `require': no such file to load -- yajl/yajl (LoadError). I solved it by opening /usr/lib/ruby/vendor_ruby/yajl.rb and editing line 2 to be require 'yajl' instead of 'yajl/yajl' Mar 13, 2013 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.