Ruby - LoadError - ruby

I started to mess around with ruby but I'm turning crazy with LoadError.
First of all this is my configuration:
which ruby
/home/daniele/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
and
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/daniele/.rvm/gems/ruby-1.9.3-p0
- RUBY EXECUTABLE: /home/daniele/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
- EXECUTABLE DIRECTORY: /home/daniele/.rvm/gems/ruby-1.9.3-p0/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/daniele/.rvm/gems/ruby-1.9.3-p0
- /home/daniele/.rvm/gems/ruby-1.9.3-p0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
installed gems:
bundler (1.0.21 ruby)
CFPropertyList (2.0.17)
eventmachine (0.12.10)
httparty (0.8.1)
json (1.6.4)
libxml-ruby (2.2.2)
multi_json (1.0.4)
multi_xml (0.4.1)
rake (0.9.2)
uuidtools (2.1.2)
This is my script start.rb header:
require 'xxx'#xxx.rb is in the same dir
and xxx.rb header:
require 'rubygems'
require 'eventmachine'
require 'zlib'
require 'cfpropertylist'
require 'pp'
require 'tweakSiri'
require 'interpretSiri'
Now if I run sudo ruby start.rb I get this error:
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- eventmachine (LoadError)
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from ./siriAuth.rb:2
from start.rb:2:in `require'
from start.rb:2
eventmachine and cfpropertylist are the only ones that generate errors.
When I try rvmsudo ruby start.rbI get this one:
/home/daniele/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- siriAuth (LoadError)
from /home/daniele/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from start.rb:2:in `<main>'
I guess I have a dirty installation of ruby..but I'm not sure that's the problem.
I'm trying to running someonelse's script...this was the installation script:
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
rvmsudo rvm install 1.9.3
rvm use 1.9.3 --default
rvmsudo gem install eventmachine CFPropertyList httparty json uuidtools
And the README says to run it with rvmsudo ruby start.rb

just ruby start.rb
not sure why you want to execute it with sudo. RVM gives you a local install of ruby 1.9.3
If you sudo it, you surpass your local user and ask root to execute ruby on your script which in turn will call the system ruby which is 1.8 on your system.

Related

cucumber --tag=#homepage_page --format progress --format html --out=reports/feature.html cannot load such file -- rspec (LoadError)

cucumber --tag=#homepage_page --format progress --format html --out=reports/feature.html cannot load such file -- rspec (LoadError)
When I try to generate the HTML reports, I am getting this error:
cannot load such file -- rspec (LoadError)
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/eun081/Documents/Ajay/PROJECTS/COMPLETED/Updated/Automation/features/support/env.rb:1:in `<top (required)>'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load_code_file'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:142:in `load_file'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:84:in `block in load_files!'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `each'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `load_files!'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:253:in `load_step_definitions'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:61:in `run!'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/cli/main.rb:32:in `execute!'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/bin/cucumber:8:in `<top (required)>'
/usr/local/bin/cucumber:22:in `load'
/usr/local/bin/cucumber:22:in `<main>'
Here is my
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.11
- RUBY VERSION: 2.0.0 (2015-12-16 patchlevel 648) [universal.x86_64 darwin16]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- USER INSTALLATION DIRECTORY: /Users/eun081/.gem/ruby/2.0.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- SPEC CACHE DIRECTORY: /Users/eun081/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-16
- GEM PATHS:
- /Library/Ruby/Gems/2.0.0
- /Users/eun081/.gem/ruby/2.0.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/eun081/.rvm/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/eun081/.rvm/bin
Here is my env.rb:-
require 'rspec'
require 'watir-webdriver'
require 'cucumber'
require 'rake'
require 'spreadsheet'
require 'yaml'
require 'page-object'
require 'yaml'
Here is my gem file:-
source "http://rubygems.org"
gem of "rake"
gem "cucumber"
gem "rspec"
#gem "watir-webdriver"
gem 'selenium-webdriver','~>2.53.0'
gem 'watir-webdriver','~>0.9.1'
gem 'spreadsheet'
gem 'rubyXL'
gem 'roo'
gem 'page-object'
gem 'require_all'
gem 'faker'
gem 'parallel_tests', '~> 2.2', '>= 2.2.2'
gem 'nokogiri', '1.3.3'
The answer was in the very first comment 'is rspec installed?' From the list of gems you give in your comments it looks a lot like you have some parts of rspec installed, but not the base rspec gem itself.
You need to run the command gem install rspec (or if you are in the directory with the gem file you listed, you should be able to just run Bundle Install, but it does need to be from that directory, for bundler to find the gemfile)
Clearly you believe you have rspec installed as you have maintained that when asked about it, but the error indicates otherwise. If you need more proof that this is the issue, see below.
On a clean system just now without rspec installed, my original gem list output showed no gems with rspec in the name..
I then ran gem install rspec, and after that was done when I ran gem list rspec I got the following
C:\Users\chuckv>gem list rspec
*** LOCAL GEMS ***
rspec (3.6.0)
rspec-core (3.6.0)
rspec-expectations (3.6.0)
rspec-mocks (3.6.0)
rspec-support (3.6.0)
I can then start an IRB session and do require 'rspec' and it works like thus..
C:\Users\chuckv>irb
irb(main):001:0> require 'rspec'
=> true
If I run gem uninstall rspec then it removes JUST the base rspec gem, leaving the others, creating a gem list output that looks similar to what you put in the comments. If I start an IRB session and do require 'rspec' then I get basically the same error you did (sans the cucumber call stack)
C:\Users\chuckv>gem list rspec
*** LOCAL GEMS ***
rspec-core (3.6.0)
rspec-expectations (3.6.0)
rspec-mocks (3.6.0)
rspec-support (3.6.0)
C:\Users\chuckv>irb
irb(main):001:0> require 'rspec'
LoadError: cannot load such file -- rspec
from C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from (irb):1
from C:/Ruby22/bin/irb:11:in `<main>'
If I then run gem install rspec I am back to having rspec in the output of gem list rspec and the require command works once again.

Why can't find the library: no such file to load

I'm stuck, can't find the cause, it's suppossed to be simple,
This is the error message:
require': no such file to load -- ./ip (LoadError)
It's generated by this line of code:
require './ip'
As the
require 'socket'
works and I found the two libraries:
/usr/lib/ruby/gems/1.8/gems/ruby-ip-0.9.1/lib/ip.rb
/usr/lib/ruby/gems/1.8/gems/ruby-ip-0.9.1/lib/ip/socket.rb
tried also require 'ip'
and
require '../ip'
still same error
Backgroun info:
I installled ruby-ip so that I could invoke a method like: ip = IP.new do ...
gem installed ruby-ip
I can see the library ( I believe it's the ip.rb what I need to use;
pwd
/usr/lib/ruby/gems/1.8/gems/ruby-ip-0.9.1/lib
ls
ip ip.rb
environment info
ruby -v
ruby 1.8.7 (2012-10-12 patchlevel 371) [i386-linux]
gem list
*** LOCAL GEMS ***
builder (3.2.0)
eventmachine (1.0.1, 0.12.10)
pg (0.14.1, 0.13.2)
ruby-ip (0.9.1)
rubygems-update (2.0.0)
sqlite3 (1.3.3)
which ruby
/usr/bin/ruby
which gem
/usr/bin/gem
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.0
- RUBY VERSION: 1.8.7 (2012-10-12 patchlevel 371) [i386-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/pilar/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Are you including require 'rubygems' too? It is necessary if you are using rvm.
Example:
[fotanus#thing ~]$ gem install ip
Fetching: ip-0.3.0.gem (100%)
Successfully installed ip-0.3.0
1 gem installed
Installing ri documentation for ip-0.3.0...
Installing RDoc documentation for ip-0.3.0...
[fotanus#thing ~]$ irb
1.8.7 :001 > require 'ip'
LoadError: no such file to load -- ip
from (irb):1:in `require'
from (irb):1
1.8.7 :002 > require 'rubygems'
=> true
1.8.7 :003 > require 'ip'
=> true
1.8.7 :004 >

cannot load such file -- mechanize.rb (LoadError) on OSX 10.6

I have a simple script:
require 'rubygems'
require 'mechanize'
p 'Success!'
When I run the script, I get:
/Users/.../.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mechanize.rb (LoadError)
from /Users/.../.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from test.rb:2:in `<main>'
In desperation I installed RVM and updated ruby from system 1.8.7. Yet I am still getting the same error as before I installed rvm. I am now running:
mute:nfg ..$ ruby -v
ruby 1.9.3p385 (2013-02-06 revision 39114) [x86_64-darwin10.8.0]
irb reports the same:
1.9.3p385 :001 > require 'rubygems'
=> false
1.9.3p385 :002 > require 'mechanize'
LoadError: cannot load such file -- mechanize
from /Users/../.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/../.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):2
from /Users/../.rvm/rubies/ruby-1.9.3-p385/bin/irb:16:in `<main>'
I have re-installed mechanize, using sudo and without, several times from the project directory.
I have tried manually requiring the gem, along with its full path.
mute:nfg ..$ ruby -l ~/.gems/gems/mechanize-2.5.1/lib/mechanize.rb
/Users/../.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mime/types (LoadError)
from /Users/../.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/../.gems/gems/mechanize-2.5.1/lib/mechanize.rb:4:in `<main>'
(I have tried installing mime-types, too.)
RVM lists the gem fine:
mute:nfg ..$ rvm all do gem list
*** LOCAL GEMS ***
...
libxml-ruby (2.3.3, 1.1.2)
mechanize (2.5.1)
mime-types (1.21, 1.19)
...
As does gem:
mute:nfg ..$ gem list
*** LOCAL GEMS ***
...
libxml-ruby (2.3.3, 1.1.2)
mechanize (2.5.1)
mime-types (1.21, 1.19)
...
Curiously, the $GEM_PATHs ~/.rvm/gems/ruby-1.9.3-p385, ~/.rvm/gems/ruby-1.9.3-p385#global and ~/.rvm/gems/ruby-1.9.3-p385#project appear mostly empty (two gems in the first, none in either of the last). However, the GUI JewelleryBox confirms that all three gemsets contain Mechanize.
EDIT: Here is the result of gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.25
- RUBY VERSION: 1.9.3 (2013-02-06 patchlevel 385) [x86_64-darwin10.8.0]
- INSTALLATION DIRECTORY: /Users/../.gems
- RUBY EXECUTABLE: /Users/../.rvm/rubies/ruby-1.9.3-p385/bin/ruby
- EXECUTABLE DIRECTORY: /Users/../.gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/../.gems
- /Users/../.gem
- /usr/lib/ruby/gems/1.8
- /Library/Ruby/Gems/1.8
- /usr/bin
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gems.github.com"]
- "gemhome" => "/Users/../.gems"
- "gempath" => ["/Users/../.gem", "/usr/lib/ruby/gems/1.8", "/Library/Ruby/Gems/1.8", "/usr/bin"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
Can anyone help?
your environment is set to use custom paths for gems, this confuses rubygems as you install to places which are not available in PATH
run rvm get head and carefully read the outputs, it will warn you about entries in *gemrc that break rubygems / RVM

Ruby 1.9.3 - cannot load such file for some reason

Ruby 1.9.3
Very simple code and very simple question I can't deal with:
gem list --local
nokogiri (1.5.5)
gem q --local
nokogiri (1.5.5)
But a ruby script (not Rails):
require 'nokogiri'
doc = Nokogiri.XML("some valid xml....")
gives me
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- nokogiri (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/alex/test.rb:3:in `<main>'
[Finished in 0.1s with exit code 1]
I'm aware that it's not necessary to use require 'rubygems', but even when I do that, it does not work either.
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/alex/.rvm/gems/ruby-1.9.3-p194
- RUBY EXECUTABLE: /home/alex/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
- EXECUTABLE DIRECTORY: /home/alex/.rvm/gems/ruby-1.9.3-p194/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/alex/.rvm/gems/ruby-1.9.3-p194
- /home/alex/.rvm/gems/ruby-1.9.3-p194#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
gem which nokogiri
/home/alex/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/lib/nokogiri.rb
It happens because of the wrong Sublime Text build system. The right one is here How to run ruby files in sublime-text-2
you need to add Nokogiri to the Gemfile (with the line gem 'nokogiri').

Installing The ruby-gmail rubygem on Mac OS Snow Leopard

I'm working off these instructions: http://github.com/dcparker/ruby-gmail
From the home directory I do a standard install and good stuff happens:
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ sudo gem install ruby-gmail
Successfully installed ruby-gmail-0.2.1
1 gem installed
Installing ri documentation for ruby-gmail-0.2.1...
Installing RDoc documentation for ruby-gmail-0.2.1...
I head over to my ~/www dir where I run scripts that include other rubygems successfully and create a gmail directory. I create a script that includes rubygems and gmail, but does nothing else:
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ pwd
/Users/johnnygoodman/www/gmail
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ ls
test-send.rb
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ cat test-send.rb
require 'rubygems'
require 'gmail'
I run this script and the errors begin:
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ ruby test-send.rb
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- mime/message (LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Gems/1.8/gems/ruby-gmail-0.2.1/lib/gmail/message.rb:1
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Gems/1.8/gems/ruby-gmail-0.2.1/lib/gmail.rb:168
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
from test-send.rb:2
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$
Here's my gem env:
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-10
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/johnnygoodman/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://rubygems.org/", "http://gems.github.com"]
- REMOTE SOURCES:
- http://rubygems.org/
- http://gems.github.com
The path that the errors give when I run the script is not the same as the GEM PATHS given in the env output. However, I don't know how to make them match or if that's the significant thing here.
sudo gem install mime
the problem with the Asif solution is than mime/message is necessary for atach any file to the mail, if you comment this line u are unable do it

Resources