views:

180

answers:

1

Can anyone help with an odd Ruby Gem problem I'm having - note I've installed many gems in the past and never seen this.

I've downloaded the net-ssh and net-sftp gems using the following commands:

sudo gem install net-ssh
sudo gem install net-sftp

both installed successfully. However when I reference the files within my code I get the following error:

./workers/ffmpeg_worker.rb:6:in `require': no such file to load -- net/ssh (LoadError)
    from ./workers/ffmpeg_worker.rb:6
    from ./workers/tests/test_ffmpeg_worker.rb:3:in `require'
    from ./workers/tests/test_ffmpeg_worker.rb:3
    from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
    from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
    from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
    from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
rake aborted!
Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]

Note when I do:

gem list --local

The gems are listed as such:

net-scp (1.0.2)
net-sftp (2.0.2, 1.1.0)
net-ssh (2.0.15, 1.1.2)
net-ssh-gateway (1.0.1)

Any clues?

+2  A: 

When I see this sort of thing, it usually comes down to having more than one Ruby installed on the machine (which means more than one gem location, etc.), and different apps or environments getting confused about which one to load.

Check for that first. If that isn't the answer, do a gem which net/ssh to see where RubyGems thinks the gem is installed -- make sure it isn't the local user's .gems directory or something.

If neither one solves the mystery, stick some debugging code into your worker script and have it output its load path ($:) so you can see where it's looking.

SFEley
Thanks, I'll try it out - but it seemed to be fixed by defining RUBYOPT as described in another question.
Justicle