Ruby 无法检测宝石

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13461873/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 05:31:39  来源:igfitidea点击:

Ruby Not Detecting Gems

rubyrubygemsrvmappfog

提问by weddingcakes

For some reason, Ruby can't seem to under stand that I installed the AppFog gem (af). When I run af, I get this:

出于某种原因,Ruby 似乎无法理解我安装了 AppFog gem ( af)。当我运行时af,我得到这个:

/Users/myface13214/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find af (>= 0) amongst [Saikuro-1.1.0, actionmailer-3.2.8, actionpack-3.2.8, activemodel-3.2.8, activerecord-3.2.8, activeresource-3.2.8, activesupport-3.2.8, arel-3.0.2, awesome_print-1.1.0, bcrypt-ruby-3.0.1, bourbon-2.1.2, builder-3.0.4, cancan-1.6.8, capistrano-2.13.5, capybara-2.0.0, cgi_multipart_eof_fix-2.5.0, childprocess-0.3.6, chronic-0.3.0, chunky_png-1.2.6, churn-0.0.24, code_analyzer-0.3.0, coffee-rails-3.2.2, coffee-script-2.2.0, coffee-script-source-1.4.0, colored-1.2, compass-0.12.2, compass-rails-1.0.3, configatron-2.9.1, cover_me-1.2.0, daemons-1.1.9, daemons-1.0.10, devise-2.1.2, diff-lcs-1.1.3, erubis-2.7.0, excon-0.16.10, execjs-1.4.0, factory_girl-4.1.0, factory_girl_rails-4.1.0, fastthread-1.0.7, ffi-1.1.5, figaro-0.5.0, flay-1.4.3, flog-2.5.3, fssm-0.2.9, gem_plugin-0.2.3, hashie-1.2.0, highline-1.6.15, hike-1.2.1, hirb-0.7.0, i18n-0.6.1, journey-1.0.4, jquery-rails-2.1.3, json-1.7.5, json_pure-1.7.5, kgio-2.7.4, libwebsocket-0.1.6, mail-2.4.4, main-4.7.1, metric_fu-2.1.1, metrical-0.1.0, mime-types-1.19, mongrel-1.2.0.pre2, multi_json-1.3.7, net-scp-1.0.4, net-sftp-2.0.5, net-ssh-2.6.1, net-ssh-gateway-1.1.0, nokogiri-1.5.5, orm_adapter-0.4.0, polyglot-0.3.3, progressbar-0.11.0, rack-1.4.1, rack-cache-1.2, rack-ssl-1.3.2, rack-test-0.6.2, rails-3.2.8, rails_best_practices-1.12.0, railties-3.2.8, raindrops-0.10.0, rake-10.0.1, rcov-0.9.11, rdoc-3.12, reek-1.2.12, ripper_ruby_parser-0.0.8, roodi-2.1.0, rspec-core-2.12.0, rspec-expectations-2.12.0, rspec-mocks-2.12.0, rspec-rails-2.12.0, ruby2ruby-1.2.5, ruby_parser-2.3.1, rubyzip-0.9.9, sass-3.2.3, sass-rails-3.2.5, selenium-webdriver-2.26.0, sexp_processor-3.2.0, sprockets-2.1.3, sqlite3-1.3.6, syntax-1.0.0, thor-0.16.0, tilt-1.3.3, treetop-1.4.12, tzinfo-0.3.35, uglifier-1.3.0, unicorn-4.4.0, vcr-2.3.0, warden-1.2.1, websocket-1.0.2, xpath-1.0.0, yamler-0.1.0] (Gem::LoadError)
    from /Users/myface13214/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
    from /Users/myface13214/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in `gem'
    from /Users/myface13214/.rvm/gems/ruby-1.9.3-p327/bin/af:18:in `<main>'
    from /Users/myface13214/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval'
    from /Users/myface13214/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `<main>'

This is even after installing it. For some reason gem installwon't install it. If it helps, I'm running 1.9.3 installed through RVM.

安装后也是这样。由于某种原因gem install不会安装它。如果有帮助,我正在运行通过 RVM 安装的 1.9.3。

回答by vgoff

You didn't really show what you were using it with, so I am going to outline some troubleshooting and installation steps that I have used to install this. A clean gemset, the latest rvm, and recording it as I do it to post here.

您并没有真正展示您使用它的内容,因此我将概述我用来安装它的一些故障排除和安装步骤。一个干净的gemset,最新的rvm,并记录它,因为我这样做是为了张贴在这里。

The first thing you will want to confirm is your rvmenvironment. I did these two steps:

您首先要确认的是您的rvm环境。我做了这两个步骤:

$: rvm get head
$: rvm use 1.9.3-p327

And then:

进而:

$: rvm info

which finally gives me this report:

最终给了我这份报告:

ruby-1.9.3-p327@CleanProject:

  system:
    uname:       "Linux lazurus 3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:32:50 UTC 2012 i686 i686 i386 GNU/Linux"
    system:      "debian/wheezy_sid/i386"
    bash:        "/bin/bash => GNU bash, version 4.2.24(1)-release (i686-pc-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.16.20 (master) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]"
    updated:      "13 minutes 59 seconds ago"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.3p327"
    date:         "2012-11-10"
    platform:     "i686-linux"
    patchlevel:   "2012-11-10 revision 37606"
    full_version: "ruby 1.9.3p327 (2012-11-10 revision 37606) [i686-linux]"

  homes:
    gem:          "/home/some_user/.rvm/gems/ruby-1.9.3-p327@CleanProject"
    ruby:         "/home/some_user/.rvm/rubies/ruby-1.9.3-p327"

  binaries:
    ruby:         "/home/some_user/.rvm/rubies/ruby-1.9.3-p327/bin/ruby"
    irb:          "/home/some_user/.rvm/rubies/ruby-1.9.3-p327/bin/irb"
    gem:          "/home/some_user/.rvm/rubies/ruby-1.9.3-p327/bin/gem"
    rake:         "/home/some_user/.rvm/gems/ruby-1.9.3-p327@global/bin/rake"

  environment:
    PATH:         "/home/some_user/.rvm/gems/ruby-1.9.3-p327@CleanProject/bin:/home/some_user/.rvm/gems/ruby-1.9.3-p327@global/bin:/home/some_user/.rvm/rubies/ruby-1.9.3-p327/bin:/home/some_user/.rvm/bin:/usr/local/heroku/bin:/home/some_user/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java-6-sun/bin"
    GEM_HOME:     "/home/some_user/.rvm/gems/ruby-1.9.3-p327@CleanProject"
    GEM_PATH:     "/home/some_user/.rvm/gems/ruby-1.9.3-p327@CleanProject:/home/some_user/.rvm/gems/ruby-1.9.3-p327@global"
    MY_RUBY_HOME: "/home/some_user/.rvm/rubies/ruby-1.9.3-p327"
    IRBRC:        "/home/some_user/.rvm/rubies/ruby-1.9.3-p327/.irbrc"
    RUBYOPT:      ""
    gemset:       "CleanProject"

I have a clean gemset, no Gemfileso no bundle install. Simply this:

我有一个干净的宝石,没有Gemfile所以没有bundle install。简单的这个:

 $: gem install af --no-rdoc --no-ri       
Fetching: json_pure-1.6.7.gem (100%)       
Fetching: rubyzip-0.9.9.gem (100%)         
Fetching: mime-types-1.19.gem (100%)       
Fetching: rest-client-1.6.7.gem (100%)     
Fetching: terminal-table-1.4.5.gem (100%)  
Fetching: interact-0.4.8.gem (100%)        
Fetching: addressable-2.2.8.gem (100%)     
Fetching: uuidtools-2.1.3.gem (100%)       
Fetching: rb-readline-0.4.2.gem (100%)     
Fetching: af-0.3.18.11.gem (100%)          
Successfully installed json_pure-1.6.7     
Successfully installed rubyzip-0.9.9       
Successfully installed mime-types-1.19     
Successfully installed rest-client-1.6.7   
Successfully installed terminal-table-1.4.5
Successfully installed interact-0.4.8      
Successfully installed addressable-2.2.8   
Successfully installed uuidtools-2.1.3     
Successfully installed rb-readline-0.4.2   
Successfully installed af-0.3.18.11        
10 gems installed                          

Then I check for the gems binary, so that I know it installs it.

然后我检查 gems 二进制文件,以便我知道它安装了它。

$: which af
/home/some_user/.rvm/gems/ruby-1.9.3-p327@CleanProject/bin/af

And when I do an directory listing:

当我做目录列表时:

$: ls /home/some_user/.rvm/gems/ruby-1.9.3-p327@CleanProject/bin/
af
restclient

This is where it seems yours breaks...

这就是你的崩溃的地方......

 $: af
Usage: af [options] command [<args>] [command_options]
Try 'af help [command]' or 'af help options' for more information.

And further, I can run the help option:

此外,我可以运行帮助选项:

$: af help

I get the help screen

我得到帮助屏幕

Usage: af [options] command [<args>] [command_options]
Try 'af help [command]' or 'af help options' for more information.

Currently available af commands are:

  Getting Started
    target [url]                                 Reports current target or sets a new 

|
|  quite a few lines cut out for brevity's sake
|    

  Help
    help [command]                               Get general help or help on a specific command
    help options                                 Get help on available options

Of course, when I check the folders that are reflected in the rvm info, I see the afbinary alongside the others.

当然,当我检查 rvm 信息中反映的文件夹时,我会看到af二进制文件与其他文件并列。

回答by tadman

Sometimes rvmmay not be fully engaged which means your $GEM_PATHenvironment variable is not set correctly. Typically rvm use 1.9.3will fix that.

有时rvm可能没有完全参与,这意味着您的$GEM_PATH环境变量设置不正确。通常rvm use 1.9.3会解决这个问题。

It may be that your rvminstall is out of date or needs to be adjusted so that your default Ruby is set correctly.

可能是您的rvm安装已过时或需要进行调整,以便正确设置您的默认 Ruby。

回答by Jasdeep Singh

please do the following, in the project root:

请在项目根目录中执行以下操作:

rvm use 1.9.3

rvm use 1.9.3

rvm gemset create your-project-name

rvm gemset create your-project-name

rvm gemset use your-project-name

rvm gemset use your-project-name

bundle install

bundle install

And see if everything s working as expected.

看看是否一切都按预期工作。