Ruby on Rails——在任何源代码中都找不到xpath-2.0.0。

时间:2022-12-14 20:38:50

Trying to run 'rails g rspec:install' and keep running into error:

尝试运行“rails g rspec:install”并持续运行错误:

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

I am running ruby 2.2.0p0 rails 4.2.0

我正在运行ruby 2.2.0p0 rails 4.2.0。

I have tried looking around for answers, but as I am relatively new to ruby and rails I couldn't find an answer. I have tried some of the following suggestions from other threads to no avail:

我试着四处寻找答案,但由于我对ruby和rails比较陌生,所以找不到答案。我已经尝试了一些其他的建议,但没有用:

sometimes we doesn’t get response from http://rubygems.org/ so it will shows error again try gem install rake to install latest version (10.0.4) of rake, and next bundle update rake to update the Gemfile.lock

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

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

(在任何一种资料中都找不到10.0.4的数据(Bundler: GemNotFound))

and

Try to delete Gemfile.lock and bundle install

试着删除Gemfile。锁和包安装

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

(在任何一种资料中都找不到10.0.4的数据(Bundler: GemNotFound))

no luck with any of those options.

这些选择都不走运。

GemFile:

GemFile:

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

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 Environment:

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/

which gem

这宝石

/usr/bin/gem

which bundle

这包

/usr/bin/bundle

3 个解决方案

#1


1  

Yes, new version of RudyOnRails has some conflicts with Spring. Just try type in console spring stop and rerun rails generate rspec:install

是的,新版本的RudyOnRails与Spring有些冲突。在控制台spring stop中尝试输入类型并重新运行rails生成rspec:install。

Find out more info in https://github.com/rspec/rspec-rails/issues/996

请在https://github.com/rspec/rspec-rails/es/996找到更多信息。

#2


1  

Not sure what the hang up would be as it's listed as a dependency of Capybara, but have you tried:

不知道挂起的东西会是什么,因为它被列为Capybara的附属品,但是你试过了吗?

gem install xpath -v '2.0.0'

gem安装xpath -v '2.0.0'

If that succeeds, rerun your bundle install.

如果成功,重新运行您的bundle安装。

Edit:

编辑:

It looks like you're trying to use RBENV, but your gems are installing to your system version of Ruby. First, you should never have to use sudo on a gem install using RVM or RBENV.

看起来您正在尝试使用RBENV,但是您的gems正在安装到您的系统版本的Ruby中。首先,您不应该使用RVM或RBENV在gem安装上使用sudo。

Taken from the RBENV install documentation: https://github.com/sstephenson/rbenv

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

It looks like step 3 might have been skipped, so verify by running from step 4:

看起来第3步可能被跳过了,所以请从步骤4中运行:

type rbenv
#=> "rbenv is a function"

If this fails, you'll need to add eval "$(rbenv init -)" to your shell (.bash_profile, .bashrc or .zshrc depending on what OS and shell you're running).

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

Make sure to restart your terminal for any shell changes to take effect.

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

Run rbenv rehash then you should get something like this when you run which gem again:

运行rbenv rehash,当你再次运行gem时你应该得到这样的东西:

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

If this works, run gem install bundle, cd into your project directory and bundle install should work.

如果这是可行的,运行gem安装包,cd到您的项目目录和bundle安装应该工作。

#3


0  

It looks like I had a bad install of rbenv. After a reinstall it fixed the issue.

看起来我安装的rbenv很糟糕。在重新安装之后,它解决了这个问题。

#1


1  

Yes, new version of RudyOnRails has some conflicts with Spring. Just try type in console spring stop and rerun rails generate rspec:install

是的,新版本的RudyOnRails与Spring有些冲突。在控制台spring stop中尝试输入类型并重新运行rails生成rspec:install。

Find out more info in https://github.com/rspec/rspec-rails/issues/996

请在https://github.com/rspec/rspec-rails/es/996找到更多信息。

#2


1  

Not sure what the hang up would be as it's listed as a dependency of Capybara, but have you tried:

不知道挂起的东西会是什么,因为它被列为Capybara的附属品,但是你试过了吗?

gem install xpath -v '2.0.0'

gem安装xpath -v '2.0.0'

If that succeeds, rerun your bundle install.

如果成功,重新运行您的bundle安装。

Edit:

编辑:

It looks like you're trying to use RBENV, but your gems are installing to your system version of Ruby. First, you should never have to use sudo on a gem install using RVM or RBENV.

看起来您正在尝试使用RBENV,但是您的gems正在安装到您的系统版本的Ruby中。首先,您不应该使用RVM或RBENV在gem安装上使用sudo。

Taken from the RBENV install documentation: https://github.com/sstephenson/rbenv

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

It looks like step 3 might have been skipped, so verify by running from step 4:

看起来第3步可能被跳过了,所以请从步骤4中运行:

type rbenv
#=> "rbenv is a function"

If this fails, you'll need to add eval "$(rbenv init -)" to your shell (.bash_profile, .bashrc or .zshrc depending on what OS and shell you're running).

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

Make sure to restart your terminal for any shell changes to take effect.

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

Run rbenv rehash then you should get something like this when you run which gem again:

运行rbenv rehash,当你再次运行gem时你应该得到这样的东西:

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

If this works, run gem install bundle, cd into your project directory and bundle install should work.

如果这是可行的,运行gem安装包,cd到您的项目目录和bundle安装应该工作。

#3


0  

It looks like I had a bad install of rbenv. After a reinstall it fixed the issue.

看起来我安装的rbenv很糟糕。在重新安装之后,它解决了这个问题。