我开始乱用ruby,但我对LoadError感到很疯狂。 首先,这是我的配置:
which ruby
/home/daniele/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
和
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/
安装了宝石:
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)
这是我的脚本start.rb
标题:
require 'xxx'#xxx.rb is in the same dir
和xxx.rb标题:
require 'rubygems'
require 'eventmachine'
require 'zlib'
require 'cfpropertylist'
require 'pp'
require 'tweakSiri'
require 'interpretSiri'
现在,如果我运行sudo ruby start.rb
,我会收到此错误:
/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和cfpropertylist是唯一产生错误的人。
当我尝试rvmsudo ruby start.rb
时,我得到了这个:
/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>'
我想我有一个肮脏的红宝石装置..但我不确定是不是问题所在。 我试图运行一些脚本...这是安装脚本:
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
README说用rvmsudo ruby start.rb
运行它答案 0 :(得分:2)
只是ruby start.rb
不确定为什么要用sudo执行它。 RVM为您提供本地安装的ruby 1.9.3 如果你sudo它,你超过你的本地用户并要求root在你的脚本上执行ruby,这反过来会调用系统上的系统ruby 1.8。