Cannot load Nokogiri - ruby

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:

Related

Getting Load error -- watir-webdriver on Mac Yosemite

I have Ruby 2.2.2, I have already watir-webdriver gem installed, when I run following script
require 'rubygems'
require 'watir-webdriver'
browser = Watir::Browser.new :firefox
It gives in
`require': cannot load such file -- watir-webdriver(LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
I have rubymine 7.1.2
Here is my gem list
$ gem list
* LOCAL GEMS *
bigdecimal (1.2.6)
bundler (1.10.3)
bundler-unload (1.0.2)
childprocess (0.5.6)
executable-hooks (1.3.2)
ffi (1.9.8)
gem-wrappers (1.2.7)
io-console (0.4.3)
json (1.8.1)
multi_json (1.11.1)
psych (2.0.8)
rake (10.4.2)
rdoc (4.2.0)
rubygems-bundler (1.4.4)
rubyzip (1.1.7)
rvm (1.11.3.9)
selenium-webdriver (2.46.2)
watir-webdriver (0.7.0)
websocket (1.2.2)
yard (0.8.7.6)
Please suggest what to do?
/System/Library/Frameworks/Ruby.framework/Versions/2.0/... is the system library in OS X Yosemite.
Ruby 2.2 (or any other version) is installed by you or some other user -- perhaps via RVM, given you have some rvm gem installed? If so you need to use RVM to change the default. If you did not install RVM correctly or ignored some warning or command it gave to you, you might want to re-install.
If you did not install Ruby 2.2 via RVM*, here are instructions for changing OS X default Ruby installed using Brew.
(*I could not recommend RVM more strongly. Other people like rbenv to do the same job.)

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

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

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

How to solve " uninitialized constant Clockwork (NameError)"

I successfully installed gem clockwork
C:\web>gem install clockwork
Successfully installed clockwork-0.2.3
1 gem installed
Installing ri documentation for clockwork-0.2.3...
Installing RDoc documentation for clockwork-0.2.3...
but when running simple script
require 'rubygems'
require 'clockwork'
include Clockwork
every(1.minute, 'custom.event.handler' ) do
puts "This event has its own handler - #{Time.new.strftime("%Y%m%d%H%M%S")}"
end
I get this error
C:\web>ruby clockwork.rb
./clockwork.rb:3: uninitialized constant Clockwork (NameError)
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
from clockwork.rb:2
Any suggestion how to make clockwork work on
Windows XP
ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
gem 1.3.7
C:\web>gem list --local
*** LOCAL GEMS ***
aaronh-chronic (0.3.9)
activesupport (3.0.9)
backports (1.18.2)
clockwork (0.2.3)
daemons (1.1.0)
delayed_job (2.0.3)
eventmachine (0.12.10 x86-mswin32-60)
fastercsv (1.5.4)
haml (3.0.21)
i18n (0.6.0)
json (1.5.1)
mechanize (1.0.0)
monkey-lib (0.5.4)
nokogiri (1.5.0 x86-mingw32, 1.4.3.1 x86-mingw32)
rack (1.2.1)
rdiscount (1.6.8)
ruby-growl (3.0)
sinatra (1.2.6, 1.0)
sinatra-advanced-routes (0.5.1)
sinatra-reloader (0.5.0)
sinatra-sugar (0.5.1, 0.5.0)
thin (1.2.7 x86-mswin32)
tilt (1.3)
Let me give you a hint. The name of your own program is clockwork.rb, and in it you do:
require 'clockwork'
See the problem?
you need to include the following in your clock.rb
require './config/boot'
require './coonfig/environment'

Resources