1

I have a very simple controller:

require 'net/ssh'

class MyController < ApplicationController
    def foo
        render :text => 'bar'
    end
end

But when I request http://server:3000/my/foo I get:

MissingSourceFile in MyController#foo 
no such file to load -- net/ssh

The gem is installed

> gem list net-ssh

*** LOCAL GEMS ***
net-ssh (2.0.11)

Also, I tried require 'net/ssh' in IRB, and it works.

MyController works fine on Windows, but fail on Ubuntu.

What can be wrong?

alex2k8
  • 42,496
  • 57
  • 170
  • 221
  • This error occurs on a fresh install of Mac OS Leopard - I have had the exact same issue trying to use the default net-sftp. – Justicle Oct 27 '09 at 05:39

6 Answers6

3

In a project I am working on we have used the config/environment.rb file to hold the gem require stuff. So

Rails::Initializer.run do |config|
  # ...
  config.gem 'net-ssh'
  config.gem 'daemons'
  config.gem 'slave'
  config.gem 'vpim'
  config.gem 'json'
  # ...
end

I think you will require 'net-ssh' rather than 'net/ssh'. However we did run into a problem where have a hyphen in the name of the gem led to failures. Then we had to do

  config.gem 'Ruby-IRC', :lib => 'IRC'

so that version maybe required for you. So that would be

  config.gem 'net-ssh', :lib => 'net/ssh'
Hamish Downer
  • 16,603
  • 16
  • 90
  • 84
2

in case of rails 3.0 this solution if OK. add this in the yourapp/Gemfile,

gem 'net-ssh
Bohdan
  • 8,298
  • 6
  • 41
  • 51
yeer
  • 482
  • 1
  • 4
  • 12
1

In my case, since it's a stand alone ruby app, I only needed to require rubygems.

1

This may help:

Rails Gem Dependencies and Plugin Errors

This is also worth watching:

Railscasts: Gem Dependencies

srboisvert
  • 12,679
  • 15
  • 63
  • 87
  • Thank you! I added [config.gem 'net-ssh', :lib => "net/ssh"] into environment.rb and executed [rake gems:install]. Now it works. – alex2k8 May 27 '09 at 14:19
0

You can also use Dr Nic's ''gemsonrails'' and load vendored gems as plugins, check: http://gemsonrails.rubyforge.org

Oinak
  • 1,805
  • 1
  • 12
  • 13
0

I think, the original problem was that I used normal user instead of root:

$ gem install net-ssh
  WARNING:  Installing to ~/.gem since /usr/lib/ruby/gems/1.8 and
            /usr/bin aren't both writable.
  WARNING:  You don't have /home/alex/.gem/ruby/1.8/bin in your PATH,
            gem executables will not run.

So, I guess, rails could not find this gem.

alex2k8
  • 42,496
  • 57
  • 170
  • 221