【问题标题】:Ruby on Rails - Could not find xpath-2.0.0 in any of the sourcesRuby on Rails - 在任何源中都找不到 xpath-2.0.0
【发布时间】:2015-04-03 08:19:11
【问题描述】:

尝试运行“rails g rspec:install”并不断出错:

Could not find xpath-2.0.0 in any of the sources
Run `bundle install` to install missing gems.

我在跑步 红宝石 2.2.0p0 轨道 4.2.0

我曾尝试四处寻找答案,但由于我对 ruby​​ 和 rails 比较陌生,所以我找不到答案。我尝试了其他线程的以下一些建议,但无济于事:

有时我们没有收到来自http://rubygems.org/ 的响应,所以它会再次显示错误尝试 gem install rake 安装最新版本 (10.0.4) 的 rake,然后下一个包更新 rake 以更新 Gemfile.lock

(Could not find rake-10.0.4 in any of the sources (Bundler::GemNotFound))

尝试删除 Gemfile.lock 并捆绑安装

(Could not find rake-10.0.4 in any of the sources (Bundler::GemNotFound))

这些选项都不行。

宝石文件:

source 'https://rubygems.org'

gem 'rails', '4.2.0'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :test do
  gem 'byebug'
  gem 'web-console', '~> 2.0'
  gem 'spring'
  gem 'rspec-rails', '~> 2.0'
end

group :test do
    gem 'capybara', '~>2.1.0'
end

Gemfile.lock

 GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.2.0)
      actionpack (= 4.2.0)
      actionview (= 4.2.0)
      activejob (= 4.2.0)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.0)
      actionview (= 4.2.0)
      activesupport (= 4.2.0)
      rack (~> 1.6.0)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    actionview (4.2.0)
      activesupport (= 4.2.0)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    activejob (4.2.0)
      activesupport (= 4.2.0)
      globalid (>= 0.3.0)
    activemodel (4.2.0)
      activesupport (= 4.2.0)
      builder (~> 3.1)
    activerecord (4.2.0)
      activemodel (= 4.2.0)
      activesupport (= 4.2.0)
      arel (~> 6.0)
    activesupport (4.2.0)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    arel (6.0.0)
    binding_of_caller (0.7.2)
      debug_inspector (>= 0.0.1)
    builder (3.2.2)
    byebug (3.5.1)
      columnize (~> 0.8)
      debugger-linecache (~> 1.2)
      slop (~> 3.6)
    capybara (2.1.0)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      xpath (~> 2.0)
    coffee-rails (4.1.0)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.0)
    coffee-script (2.3.0)
      coffee-script-source
      execjs
    coffee-script-source (1.9.0)
    columnize (0.9.0)
    debug_inspector (0.0.2)
    debugger-linecache (1.2.0)
    diff-lcs (1.2.5)
    erubis (2.7.0)
    execjs (2.3.0)
    globalid (0.3.0)
      activesupport (>= 4.1.0)
    hike (1.2.3)
    i18n (0.7.0)
    jbuilder (2.2.6)
      activesupport (>= 3.0.0, < 5)
      multi_json (~> 1.2)
    jquery-rails (4.0.3)
      rails-dom-testing (~> 1.0)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    json (1.8.2)
    loofah (2.0.1)
      nokogiri (>= 1.5.9)
    mail (2.6.3)
      mime-types (>= 1.16, < 3)
    mime-types (2.4.3)
    mini_portile (0.6.2)
    minitest (5.5.1)
    multi_json (1.10.1)
    nokogiri (1.6.6.2)
      mini_portile (~> 0.6.0)
    rack (1.6.0)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.2.0)
      actionmailer (= 4.2.0)
      actionpack (= 4.2.0)
      actionview (= 4.2.0)
      activejob (= 4.2.0)
      activemodel (= 4.2.0)
      activerecord (= 4.2.0)
      activesupport (= 4.2.0)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.2.0)
      sprockets-rails
    rails-deprecated_sanitizer (1.0.3)
      activesupport (>= 4.2.0.alpha)
    rails-dom-testing (1.0.5)
      activesupport (>= 4.2.0.beta, < 5.0)
      nokogiri (~> 1.6.0)
      rails-deprecated_sanitizer (>= 1.0.1)
    rails-html-sanitizer (1.0.1)
      loofah (~> 2.0)
    railties (4.2.0)
      actionpack (= 4.2.0)
      activesupport (= 4.2.0)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.4.2)
    rdoc (4.2.0)
      json (~> 1.4)
    rspec-collection_matchers (1.1.2)
      rspec-expectations (>= 2.99.0.beta1)
    rspec-core (2.99.2)
    rspec-expectations (2.99.2)
      diff-lcs (>= 1.1.3, < 2.0)
    rspec-mocks (2.99.3)
    rspec-rails (2.99.0)
      actionpack (>= 3.0)
      activemodel (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-collection_matchers
      rspec-core (~> 2.99.0)
      rspec-expectations (~> 2.99.0)
      rspec-mocks (~> 2.99.0)
    sass (3.4.11)
    sass-rails (5.0.1)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (~> 1.1)
    sdoc (0.4.1)
      json (~> 1.7, >= 1.7.7)
      rdoc (~> 4.0)
    slop (3.6.0)
    spring (1.2.0)
    sprockets (2.12.3)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.2.4)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (>= 2.8, < 4.0)
    sqlite3 (1.3.10)
    thor (0.19.1)
    thread_safe (0.3.4)
    tilt (1.4.1)
    turbolinks (2.5.3)
      coffee-rails
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    uglifier (2.7.0)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    web-console (2.0.0)
      activemodel (~> 4.0)
      binding_of_caller (>= 0.7.2)
      railties (~> 4.0)
      sprockets-rails (>= 2.0, < 4.0)
    xpath (2.0.0)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  byebug
  capybara (~> 2.1.0)
  coffee-rails (~> 4.1.0)
  jbuilder (~> 2.0)
  jquery-rails
  rails (= 4.2.0)
  rspec-rails (~> 2.0)
  sass-rails (~> 5.0)
  sdoc (~> 0.4.0)
  spring
  sqlite3
  turbolinks
  uglifier (>= 1.3.0)
  web-console (~> 2.0)

RubyGems 环境:

  - RUBYGEMS VERSION: 2.4.5
  - RUBY VERSION: 2.0.0 (2014-05-08 patchlevel 481) [universal.x86_64-darwin14]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - SPEC CACHE DIRECTORY: /volumes/ALEX/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-14
  - GEM PATHS:
     - /Library/Ruby/Gems/2.0.0
     - /volumes/ALEX/.gem/ruby/2.0.0
     - /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Users/alexmattson/.rbenv/versions/2.2.0/bin/

哪颗宝石

/usr/bin/gem

哪个包

/usr/bin/bundle

【问题讨论】:

    标签: ruby-on-rails ruby xpath rspec


    【解决方案1】:

    不知道挂断会是什么,因为它被列为 Capybara 的依赖项,但你尝试过吗:

    gem install xpath -v '2.0.0'

    如果成功,请重新运行您的捆绑安装。

    编辑:

    看起来您正在尝试使用 RBENV,但您的 gem 正在安装到您的 Ruby 系统版本。首先,您永远不必在使用 RVM 或 RBENV 的 gem install 上使用 sudo

    取自 RBENV 安装文档:https://github.com/sstephenson/rbenv

    看起来第 3 步可能已被跳过,因此请从第 4 步开始运行验证:

    type rbenv
    #=> "rbenv is a function"
    

    如果失败,您需要将 eval "$(rbenv init -)" 添加到您的 shell(.bash_profile、.bashrc 或 .zshrc,具体取决于您运行的操作系统和 shell)。

    确保重新启动终端以使任何 shell 更改生效。

    运行 rbenv rehash 然后当你再次运行 which gem 时应该会得到类似的结果:

    which gem
    #=> /Users/your-user-name/.rbenv/shims/gem
    

    如果可行,请运行 gem install bundle,cd 进入您的项目目录,bundle install 应该可以运行。

    【讨论】:

    • gem install 工作,但重新运行 bundle install 后没有运气。
    • 运行时会得到什么:which gemwhich bundle
    • 我将它添加到帖子的末尾。另外我确定这是问题的一部分,当我进行 gem install 时,它给了我以下错误:错误:执行 gem ...(Gem::FilePermissionError)您没有 /Library/ 的写权限Ruby/Gems/2.0.0 目录。我使用 sudo 来解决它,但我认为您不需要为任何 gem 安装执行 sudo。
    【解决方案2】:

    是的,新版本的 RudyOnRails 与 Spring 存在一些冲突。只需尝试输入控制台spring stop 并重新运行rails generate rspec:install

    https://github.com/rspec/rspec-rails/issues/996了解更多信息

    【讨论】:

      【解决方案3】:

      看来我的 rbenv 安装错误。重新安装后问题解决了。

      【讨论】:

        猜你喜欢
        • 2018-08-01
        • 2016-04-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-03-02
        • 2018-08-01
        相关资源
        最近更新 更多