我不能在我的ruby文件中要求rubygems :(虽然我可以要求其他模块 - 例如rexml / document)
我的01.rb
文件:
require "rubygems"
执行ruby 01.rb
时,我得到了:
01.rb:1:in `require': no such file to load -- rubygems (LoadError)
from 01.rb:1
然而,这是我系统上某些命令的输出:
我的ruby版本(我想我有倍数,导致问题,对吧? - 我应该删除所有并从头开始重新安装吗?)
mhewedy@compu10:~$ ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
mhewedy@compu10:~$ which -a ruby
/usr/bin/ruby
mhewedy@compu10:~$ ls -lt /usr/bin/ruby
lrwxrwxrwx 1 root root 22 Sep 11 07:28 /usr/bin/ruby -> /etc/alternatives/ruby
mhewedy@compu10:~$ ls -lt /etc/alternatives/ruby
lrwxrwxrwx 1 root root 16 Sep 27 10:00 /etc/alternatives/ruby -> /usr/bin/ruby1.8
mhewedy@compu10:~$ ls /usr/bin/ruby*
/usr/bin/ruby /usr/bin/ruby1.8 /usr/bin/ruby1.9.1 /usr/bin/ruby1.9.3
这是我的宝石环境
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/mhewedy/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
答案 0 :(得分:0)
我通过将system-wide ruby
版本(which ruby
的结果,/usr/bin/ruby
)指向输出中的同一个版本来解决此问题 gen env
- 1.9.1
。
我做了这个 - 在我的ubuntu盒子里 - 使用:
sudo update-alternatives --config ruby
然后选择与gem env