虽然安装了红宝石宝石,但没有找到 [英] ruby gem not found although it is installed

查看:96
本文介绍了虽然安装了红宝石宝石,但没有找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里发现了一些类似的问题,但没有一个与我的案例相匹配(对不起,如果我忽略了)。这是我的问题:我安装了oauth-plugin gem到ruby gem dir,但试图在rails应用程序中使用它告诉我它没有被找到。以下是相关命令的输出:

安装

 %s gem安装oauth-plugin 
成功安装oauth-plugin-0.3.14
1安装gem
为oauth-plugin-0.3.14安装ri文档...
安装RDoc文档oauth-plugin-0.3.14 ...

gem which oauth-plugin 输出:

 %gem其中oauth-plugin 
/ usr / lib / ruby​​ / gems / 1.8 / gems / oauth-plugin-0.3.14 / lib / oauth-plugin.rb

gem env 输出:

 %gem env 
RubyGems环境:
- RUBYGEMS VERSION:1.3.6
- RUBY VERSION:1.8.7(2009-12-24 patchlevel 248)[i686-darwin10.2.0]
- 安装目录:/ usr / lib / ruby​​ / gems / 1.8
- RUBY EXECUTABLE:/ usr / bin / ruby​​
- 可执行目录:/ usr / bin
- RUBYGEMS平台:
- ruby​​
- x86-darwin-10
- 创业板路径:
- / u sr / lib / ruby​​ / gems / 1.8
- /Users/eimantas/.gem/ruby/1.8
- GEM配置:
- :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/]
- 远程源:
- http://gems.ruby.lt/
- http://rubygems.org/

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

 %ls -l / usr / lib / ruby 
lrwxr-xr-x 1根轮子76 2009年8月14日/ usr / lib / ruby​​ - > ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/lib/ruby

所涉及的宝石位于预定位置。



以下是rails在尝试运行时遇到的错误 $ rake spec

 缺少这些所需的宝石:
oauth-plugin = 0.3.14

您正在运行:
ruby 1.8.7.173 at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
ruby​​gems 1.3.6位于/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

运行`rake gems:install`安装缺失的宝石。

这不是一个没有被rubygems发现的宝石(尽管它位于它应该在的位置)。非常感谢您对解决方案的任何指导。解决方案

您安装了两种不同版本的Ruby。首先是:

/ usr / bin / ruby​​



第二个是:



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



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



由于您的Web服务器使用第二个Ruby版本,是使用该Ruby版本安装gem。或者,您可以告诉您的Web服务器使用不同的Ruby版本 - 这取决于您使用的服务器可以通过不同的方式实现。


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:

Installation

% 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 output:

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

gem env output:

% 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/

Doing ls -l /usr/lib/ruby shows this:

% 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.

Here's the error that rails give me when I try running $ 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.

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.

解决方案

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

/usr/bin/ruby

and second one is in:

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

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.

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.

这篇关于虽然安装了红宝石宝石,但没有找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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