`require': cannot load such file -- net/ssh (LoadError) - ruby

run a ruby script got error `require': cannot load such file -- net/ssh (LoadError)
bash-3.2$ rvm --default ruby-2.0.0-p451
-bash-3.2$ rvm list
rvm rubies
=* ruby-2.0.0-p451 [ x86_64 ]
-bash-3.2$ gem list --local
*** LOCAL GEMS ***
bigdecimal (1.2.0)
bundler (1.5.3)
bundler-unload (1.0.2)
executable-hooks (1.3.1)
gem-wrappers (1.2.4)
io-console (0.4.2)
json (1.7.7)
minitest (4.3.2)
net-ssh (2.9.1)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
rubygems-bundler (1.4.2)
rvm (1.11.3.9)
test-unit (2.0.0.0)
ruby test.rb
`require': no such file to load -- rubygems (LoadError)
$ cat test.rb
require 'rubygems'
require 'net/ssh'
Net::SSH.start(...)
what's wrong? please advice. thanks

Related

RVM works, Ruby gems installed, but not accessible with require

Here’s my problem:
➜ ~ rvm current
ruby-2.2.1
➜ ~ rvm list
rvm rubies
ruby-2.0.0-p643 [ x86_64 ]
ruby-2.1.1 [ x86_64 ]
=* ruby-2.2.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
➜ ~ ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
➜ ~ gem list
*** LOCAL GEMS ***
bigdecimal (1.2.6)
bundler (1.10.6)
coderay (1.1.0)
domain_name (0.5.24)
http-cookie (1.0.2)
io-console (0.4.3)
json (1.8.1)
method_source (0.8.2)
mime-types (2.6.1)
netrc (0.10.3)
plaid-ruby (0.1.2)
plist (3.1.0)
pry (0.10.1)
psych (2.0.8)
rake (10.4.2)
rdoc (4.2.0)
rest-client (1.8.0)
slop (3.6.0)
unf (0.1.4)
unf_ext (0.0.7.1)
➜ ~ irb
irb(main):001:0> require 'plaid-ruby'
LoadError: cannot load such file -- plaid-ruby
from /Users/richardburton/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/richardburton/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from (irb):1
from /Users/richardburton/.rvm/rubies/ruby-2.2.1/bin/irb:11:in `<main>'
irb(main):002:0>
You need to require plaid, not plaid-ruby. The file you require doesn’t necessarily have the same name as the gem, although it’s often the case that it does.
In fact from the Rubygems page for plaid-ruby and the Github page it links to it looks like it is an old version of the Plaid client, and you should be using the plaid gem.

rvm `require': no such file to load -- rubygems (LoadError)

run a ruby code got error "rvm `require': no such file to load -- rubygems (LoadError)"
bash-3.2$ rvm --default ruby-2.0.0-p451
-bash-3.2$ rvm list
rvm rubies
=* ruby-2.0.0-p451 [ x86_64 ]
-bash-3.2$ gem list --local
*** LOCAL GEMS ***
bigdecimal (1.2.0)
bundler (1.5.3)
bundler-unload (1.0.2)
executable-hooks (1.3.1)
gem-wrappers (1.2.4)
io-console (0.4.2)
json (1.7.7)
minitest (4.3.2)
net-ssh (2.9.1)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
rubygems-bundler (1.4.2)
rvm (1.11.3.9)
test-unit (2.0.0.0)
-bash-3.2$ gem list --local rubygems
*** LOCAL GEMS ***
rubygems-bundler (1.4.2)
to run the script:
ruby test.rb
`require': no such file to load -- rubygems (LoadError)
$ cat test.rb
require 'rubygems'
require 'net/ssh'
Net::SSH.start(.............
what's going on? please advice. thanks

Cannot load Nokogiri

I'm writing Ruby scripts on Linux Mint 14 under RVM. In both Ruby 2.0 and 1.9.3, when I try to run what I'm working on, I get the error:
/home/tom/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- Nokogiri (LoadError)
from /home/tom/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from make_index.rb:1:in `<main>'
Nokogiri is installed; gem list gives:
*** LOCAL GEMS ***
bigdecimal (1.1.0)
bundler (1.3.5)
bundler-unload (1.0.1)
io-console (0.3)
json (1.5.5)
mini_portile (0.5.1)
minitest (2.5.1)
nokogiri (1.6.0)
rake (10.1.0, 0.9.2.2)
rdoc (3.9.5)
rubygems-bundler (1.2.1)
rvm (1.11.3.8)
The file in question starts with require 'Nokogiri'. Running the file with sudo doesn't make a difference, nor does using the terminal vs. running it in Geany.
Not Nokogiri rather, you should write as below
require 'nokogiri'
See SYNOPSIS:

JRuby "no such file to load"

Using jruby-1.6.7 via rvm and gem version 1.8.24 I created a new project containing a Gemfile:
source 'http://rubygems.org'
gem 'google-api-client'
and a main.rb:
require 'google/api_client'
After
gem install bundler
bundle install
gem list
I get
addressable (2.2.8)
autoparse (0.3.1)
bouncy-castle-java (1.5.0146.1)
bundler (1.1.4)
extlib (0.9.15)
faraday (0.8.1, 0.7.6)
ffi (1.0.11 java)
google-api-client (0.4.3)
jruby-launcher (1.0.14 java)
jruby-openssl (0.7.7)
json (1.7.3 java)
jwt (0.1.4)
launchy (2.1.0 java)
multi_json (1.3.6)
multipart-post (1.1.5)
rack (1.4.1)
rake (0.9.2.2)
rubygems-bundler (1.0.2)
rubygems-update (1.8.24, 1.7.2)
rvm (1.11.3.3)
signet (0.3.4)
spoon (0.0.1)
But when I run ruby main.rb, it results in an error:
LoadError: no such file to load -- google/api_client
require at org/jruby/RubyKernel.java:1033
(root) at main.rb:1
On MRI everything seems to be working fine. The problem does not seem bound to any specific gem.
Can someone help me with this?
Unless you have JRUBY_OPTS=--1.9 in your environment, or you pass the --1.9 flag on the command line, JRuby will default to 1.8 mode, which means that you explicitly have to require 'rubygems' in main.rb before you load your gems.

Unable to run ruby-debug on ruby1.9.3p0 under XP

How do I get ruby-debug to run under XP so that I can step through my Watir test scripts.
I am unable to "require" ruby-debug on Windows XP. All of the solutions I have seen refer to a Unix-based system running Rails. Here is my system profile:
H:\>ruby -v
ruby 1.9.3p0 (2011-10-30) [i386-mingw32]
Here are the gems I have installed to support my testing in Watir
H:\>gem list
*** LOCAL GEMS ***
archive-tar-minitar (0.5.2)
awesome_print (1.0.2)
bigdecimal (1.1.0)
childprocess (0.2.4)
columnize (0.3.6)
ffi (1.0.11)
io-console (0.3)
json (1.5.4)
linecache19 (0.5.13)
minitest (2.5.1)
mkrf (0.2.3)
multi_json (1.0.4)
net-ssh (2.2.1)
rake (0.9.2.2)
rdebug (0.1)
rdiscount (1.6.8)
rdoc (3.9.4)
ruby-debug-base19x (0.11.30.pre4)
ruby_core_source (0.1.5)
rubygems-update (1.8.13)
rubyzip (0.9.5)
selenium-webdriver (2.15.0)
watir-webdriver (0.4.1)
wirble (0.1.3)
This is the error that presents itself when I try to "require" ruby-debug.
Error:
irb(main):001:0> require 'ruby-debug'
LoadError: cannot load such file -- ruby-debug
from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):1
from C:/Ruby/bin/irb:12:in `<main>'
irb(main):002:0>
ruby-debug has been broken with recent ruby versions for a very long time. Try the debugger gem instead. I've no idea if it works on Windows though.
try this
gem install ruby-debug --pre

Resources