本文介绍了即使已安装 Ruby gem 也不会加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道关于 SO 有类似的问题,但没有一个能解决我的问题...主要是我无法在 Ubuntu 10.04 上安装干净的 Ruby 1.9.1 时加载 gem:

I know there's similar questions on SO, but none of them solve my problem... The gist of it is that I can't get gems to load on a clean Ruby 1.9.1 install on Ubuntu 10.04:

:~/$ irb
irb(main):001:0> require 'rubygems'
=> false
irb(main):002:0> require 'cassandra'
LoadError: no such file to load -- cassandra
    from (irb):1:in 'require'
    from (irb):1
    from /usr/local/bin/irb:12:in '<main>'
irb(main):003:0> Gem.path

=> ["/opt/ruby1.9/lib/ruby1.9/gems/1.9.1"]
irb(main):004:0> exit

:~/$ ls /opt/ruby1.9/lib/ruby/gems/1.9.1/gems/
cassandra-0.8.2  eventmachine-0.12.10  json-1.4.6  rake-0.8.7  simple_uuid-0.1.1  thrift-0.2.0.4  thrift-0.4.0  thrift_client-0.5.0

:~/$ gem list --local

*** LOCAL GEMS ***

cassandra (0.8.2)
eventmachine (0.12.10)
json (1.4.6)
rake (0.8.7)
simple_uuid (0.1.1)
thrift (0.4.0, 0.2.0.4)
thrift_client (0.5.0)

:~/$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.9.1 (2009-05-12 patchlevel 129) [x86_64-linux]
  - INSTALLATION DIRECTORY: /opt/ruby1.9/lib/ruby/gems/1.9.1
  - RUBY EXECUTABLE: /opt/ruby1.9/bin/ruby1.9
  - EXECUTABLE DIRECTORY: /opt/ruby1.9/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /opt/ruby1.9/lib/ruby/gems/1.9.1
     - /home/mark/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

有什么想法吗?提前谢谢...

Any ideas? Thanks in advance...

推荐答案

你的 gem env 和 Gem.path 不一致.


您的 Gem.path 正在查看 ["/opt/ruby1.9/lib/ruby1.9/gems/1.9.1"] 但您的 gem env 正在查看 /opt/ruby1.9/lib/ruby/gems/1.9.1

Your gem env and Gem.path are inconsistent.


Your Gem.path is looking at ["/opt/ruby1.9/lib/ruby1.9/gems/1.9.1"] but your gem env is looking at /opt/ruby1.9/lib/ruby/gems/1.9.1

作为快速检查,为什么不从/opt/ruby1.9/lib/ruby/gems/1.9.1 创建符号链接到/opt/ruby1.9/lib/ruby1.9/gems/1.9.1 到/opt/ruby1.9/lib/ruby/gems/1.9.1

As a quick check, why not create a symlink from /opt/ruby1.9/lib/ruby/gems/1.9.1 to /opt/ruby1.9/lib/ruby1.9/gems/1.9.1 to /opt/ruby1.9/lib/ruby/gems/1.9.1

sudo ln -s /opt/ruby1.9/lib/ruby1.9/gems/1.9.1  /opt/ruby1.9/lib/ruby/gems/1.9.1

这篇关于即使已安装 Ruby gem 也不会加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 19:12