tags:

views:

228

answers:

3

I'm trying to run a ruby file which imports a gem. The ya2yaml gem is installed, yet somehow it is not found:

$ cat delme.rb  
require 'rubygems'  
require 'ya2yaml'  

$ ruby delme.rb  
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- ya2yaml (LoadError)  
        from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'  
        from delme.rb:2  

I installed the gem using:

sudo gem install ya2yaml
and I know that the gem is actually installed:

$ gem list --local | grep ya2yaml
ya2yaml (0.26)

Also, the following works from a rails program I just downloaded:

sudo rake gems
However the following fails:
rake gems
Which leads me to think that there may be a permissions problem somewhere.

Why can't the gem be found? What can I do to diagnose this?

Thanks!

A: 

I've certainly seen this error before. Unfortunately I don't know what causes it. I do know that if you see it on Linux and you've installed gem via your package manager (synaptic / yum / etc) then you can generally fix it by installing gem by hand from their website. The instructions there are pretty straight-forward.

(Your command line looks unix-y, so it seems to me that you may be on Linux. If you're on a Mac, it's certainly worth trying anyway.)

UPDATE: Linux, then. Ta.

Shadowfirebird
A: 

The thing I would do in a situation like this:

  1. Search for the gem's location on your system. Use this command:

    find / -name ya2yaml

  2. Check that the found directory is added to your PATH system variable by doing this:

    echo $PATH

  3. If the path where ya2yaml gem is located is not listed in the PATH variable's value, add it:

    PATH=$PATH:/gem/location/directory

    export PATH

I hope you'll find these steps helpful. Good luck!

Ziggy
A: 

Instead of require 'rubygems' inside delme.rb, try starting ruby with -rubygems:

$ ruby -rubygems delme.rb
Nefrubyr