Rails找不到rake-10.5.0

6
我正在尝试在Rails 4.2中安装rake宝石。似乎这个宝石已经成功安装了,但是当Rails尝试运行时失败了,并且说它看不到rake-10.5.0。我正在Rubymine中开发,下面是我收到的错误信息以及我的Gemfile。我已经尝试按照其他帖子建议删除Gemfile.lock,但没有用。

控制台:

 ~/Development/RubymineProjects/Revenant.tech    
ls
Gemfile     Rakefile    config      lib     test
Gemfile.lock    app     config.ru   log     tmp
README.rdoc bin     db      public      vendor
 ~/Development/RubymineProjects/Revenant.tech    
gem install rack
Successfully installed rack-1.6.4
Parsing documentation for rack-1.6.4
Done installing documentation for rack after 2 seconds
1 gem installed
 ~/Development/RubymineProjects/Revenant.tech    
bundle update rake
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.5.0
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.3
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using rack 1.6.4
Using mime-types 2.99
Using arel 6.0.3
Using debug_inspector 0.0.2
Using bundler 1.11.2
Using byebug 8.2.1
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using thor 0.19.1
Using concurrent-ruby 1.0.0
Using multi_json 1.11.2
Using mysql2 0.4.2
Using sass 3.4.21
Using tilt 2.0.2
Using spring 1.6.2
Using tzinfo 1.2.2
Using nokogiri 1.6.7.1
Using rack-test 0.6.3
Using mail 2.6.3
Using binding_of_caller 0.7.2
Using coffee-script 2.4.1
Using uglifier 2.7.2
Using sprockets 3.5.2
Using activesupport 4.2.5
Using loofah 2.0.3
Using rails-deprecated_sanitizer 1.0.3
Using globalid 0.3.6
Using activemodel 4.2.5
Using jbuilder 2.4.0
Using rails-html-sanitizer 1.0.2
Using rails-dom-testing 1.0.7
Using activejob 4.2.5
Using activerecord 4.2.5
Using actionview 4.2.5
Using actionpack 4.2.5
Using actionmailer 4.2.5
Using railties 4.2.5
Using sprockets-rails 3.0.0
Using coffee-rails 4.1.1
Using jquery-rails 4.1.0
Using rails 4.2.5
Using sass-rails 5.0.4
Using web-console 2.2.1
Using turbolinks 2.5.3
Bundle updated!
 ~/Development/RubymineProjects/Revenant.tech    
rm Gemfile.lock 
 ~/Development/RubymineProjects/Revenant.tech    
bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies.....
Using rake 10.5.0
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.3
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using rack 1.6.4
Using mime-types 2.99
Using arel 6.0.3
Using debug_inspector 0.0.2
Using bundler 1.11.2
Using byebug 8.2.1
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using thor 0.19.1
Using concurrent-ruby 1.0.0
Using multi_json 1.11.2
Using mysql2 0.4.2
Using sass 3.4.21
Using tilt 2.0.2
Using spring 1.6.2
Using tzinfo 1.2.2
Using nokogiri 1.6.7.1
Using rack-test 0.6.3
Using mail 2.6.3
Using binding_of_caller 0.7.2
Using coffee-script 2.4.1
Using uglifier 2.7.2
Using sprockets 3.5.2
Using activesupport 4.2.5
Using loofah 2.0.3
Using rails-deprecated_sanitizer 1.0.3
Using globalid 0.3.6
Using activemodel 4.2.5
Using jbuilder 2.4.0
Using rails-html-sanitizer 1.0.2
Using rails-dom-testing 1.0.7
Using activejob 4.2.5
Using activerecord 4.2.5
Using actionview 4.2.5
Using actionpack 4.2.5
Using actionmailer 4.2.5
Using railties 4.2.5
Using sprockets-rails 3.0.0
Using coffee-rails 4.1.1
Using jquery-rails 4.1.0
Using rails 4.2.5
Using sass-rails 5.0.4
Using web-console 2.2.1
Using turbolinks 2.5.3
Bundle complete! 12 Gemfile dependencies, 52 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
 ~/Development/RubymineProjects/Revenant.tech    

Rubymine控制台错误:
/usr/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/richardcurteis/Development/RubymineProjects/Revenant.tech/bin/rails server -b 0.0.0.0 -p 3000 -e development
/Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/spec_set.rb:94:in `block in materialize': Could not find rake-10.5.0 in any of the sources (Bundler::GemNotFound)
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/spec_set.rb:87:in `map!'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/spec_set.rb:87:in `materialize'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/definition.rb:137:in `specs'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/definition.rb:182:in `specs_for'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/definition.rb:171:in `requested_specs'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/environment.rb:18:in `requested_specs'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:13:in `setup'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler.rb:92:in `setup'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.11.2/lib/bundler/setup.rb:18:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
    from /Users/richardcurteis/Development/RubymineProjects/Revenant.tech/config/boot.rb:3:in `<top (required)>'
    from /Users/richardcurteis/Development/RubymineProjects/Revenant.tech/bin/rails:3:in `require_relative'
    from /Users/richardcurteis/Development/RubymineProjects/Revenant.tech/bin/rails:3:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'

Process finished with exit code 1

Rakefile:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.3.13', '< 0.5'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'rake'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

2
实际上,在gemfile中不需要包含gem 'rake'。尝试删除此字符串并再次删除gemfile.lock,然后执行gem install rake --version='10.5.0'bundle install - Igor Ivancha
删除Gemfile.lock的问题在于,你可能会意外地拉取与生产/暂存环境中使用的不同版本的gems。此外,仅依靠gem install来获取“正确”的rake版本只有在该步骤作为部署的一部分运行时才适用于其他环境。 - user483040
@IgorIvancha,你做到了!提前感谢你! - user6358125
2个回答

1
我想你的系统中安装了多个版本的rake。因此,要启动应用程序,请使用:
bundle exec rails s -p 3000

您可以检查系统中已安装的rake列表:gem list | grep rake

1
我在Gemfile中加入了gem 'rake', '10.5.0',但仍然出现相同的错误。 - 3therk1ll
1
我有同样的问题;@Sasidaran,我该如何检查rake安装(假设我的环境中有多个)? - t3__rry
你可以执行 gem list rake 命令来查看本地 gemset 中所有的 rake 版本。如果存在某种不匹配情况,你也可以执行 bundle show | grep rake 命令来查看与 bundler 相关的已安装版本。 - user483040
我曾经遇到过同样的问题。问题是由于多个版本的rake引起的。我卸载了所有版本,然后运行bundle install来解决这个问题。 - vulcan_hacker

1

我认为问题与我的Ruby安装有关。我运行了以下命令,似乎解决了这个问题。

rvm install ruby-2.0.0-p643
rvm --default use 2.0.0
ruby -v
ruby 2.0.0p643 (2015-02-25 revision 49749) [x86_64-darwin14.1.0]

1
提醒一下,Ruby 2.0.0已经不是最新版本了。“警告:请注意,您刚安装的Ruby已经不再维护(2016-02-24),有关维护的Ruby列表,请访问:http://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering。请考虑升级到ruby-2.3.0,这将包含所有最新的安全补丁。”因此,最好现在安装一个更新的版本。 - Fed

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接