rops
rops

Reputation: 217

Ruby - LoadError

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

Upvotes: 1

Views: 3867

Answers (1)

three
three

Reputation: 8478

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.

Upvotes: 2

Related Questions