尽管已安装 ruby​​ gem,但未找到它 [英] ruby gem not found although it is installed

查看:33
本文介绍了尽管已安装 ruby​​ gem,但未找到它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 SO 上发现了一些类似的问题,但似乎没有一个与我的情况相匹配(抱歉,如果我忽略了).这是我的问题:我将 oauth-plugin gem 安装到 ruby​​ gems 目录,但尝试在 rails 应用程序中使用它告诉我找不到它.以下是相关命令的输出:

I found some similar problems here on SO, but none seem to match my case (sorry if I overlooked). Here's my problem: I installed oauth-plugin gem to ruby gems dir, but trying to use it in rails app tells me that it's not being found. Here's the output of relevant commands:

安装

% s gem install oauth-plugin
Successfully installed oauth-plugin-0.3.14
1 gem installed
Installing ri documentation for oauth-plugin-0.3.14...
Installing RDoc documentation for oauth-plugin-0.3.14...

gem which oauth-plugin 输出:

% gem which oauth-plugin
/usr/lib/ruby/gems/1.8/gems/oauth-plugin-0.3.14/lib/oauth-plugin.rb

gem env 输出:

% gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.6
  - RUBY VERSION: 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin10.2.0]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-darwin-10
  - GEM PATHS:
     - /usr/lib/ruby/gems/1.8
     - /Users/eimantas/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => true
     - :bulk_threshold => 1000
     - :gem => ["--no-ri", "--no-rdoc"]
     - :sources => ["http://gems.ruby.lt/", "http://rubygems.org/"]
  - REMOTE SOURCES:
     - http://gems.ruby.lt/
     - http://rubygems.org/

执行 ls -l/usr/lib/ruby 显示:

% ls -l /usr/lib/ruby     
lrwxr-xr-x  1 root  wheel  76 Aug 14  2009 /usr/lib/ruby -> ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/lib/ruby

有问题的宝石位于预定位置.

And the gem in question is in intended location.

这是我尝试运行 $ rake spec

Missing these required gems:
  oauth-plugin   = 0.3.14

You're running:
  ruby 1.8.7.173 at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  rubygems 1.3.6 at /Users/eimantas/.gem/ruby/1.8, /Library/Ruby/Gems/1.8, /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8

Run `rake gems:install` to install the missing gems.

这不是一块未被 ruby​​gems 发现的宝石(尽管它位于应有的位置).非常感谢您对解决方案的任何指导.

This is not a single gem that is not being found by rubygems (although it's located where it should be). Any guidance towards the solution is much appreciated.

推荐答案

您安装了两个不同版本的 Ruby.首先是:

You have two different versions of Ruby installed. First is in:

/usr/bin/ruby

/usr/bin/ruby

第二个在:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

问题是一个用于命令行(即安装gems),另一个用于Web服务器运行Rails.

The problem is that one is used in command line (i.e. to install gems) and another is used by web server to run Rails.

由于您的 Web 服务器使用的是第二个 Ruby 版本,因此一种解决方案是使用该 Ruby 版本安装 gem.或者,您可以告诉您的 Web 服务器使用不同的 Ruby 版本 - 根据您使用的服务器,这可以通过不同的方式实现.

Since your web server is using second Ruby version one solution would be to install gem using that Ruby version. Alternatively, you can tell your web server to use different Ruby version - depending on which server you are using this can be achieved in different ways.

这篇关于尽管已安装 ruby​​ gem,但未找到它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆