我一直在阅读StackOverflow并尝试处理此错误2小时:
bundle exec rake db:setup
Could not find rake-10.4.2 in any of the sources
Run `bundle install` to install missing gems.
我按照这里的建议,无济于事:
rails s: Could not find rake-10.4.2 in any of the sources (Bundler::GemNotFound)
也:
Could not find rake with bundle exec
所以我做了:
gem uninstall rake
gem install rake
然后,按照我读过的其他StackOverflow文章,我试过了:
rbenv install 2.3.1
Downloading ruby-2.3.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
Installing ruby-2.3.1...
Installed ruby-2.3.1 to /Users/lkrubner/.rbenv/versions/2.3.1
rbenv global 2.3.1
ruby -v
ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
bundle exec rake db:setup
Could not find rake-10.4.2 in any of the sources
Run `bundle install` to install missing gems.
rbenv rehash
rbenv uninstall rake
rbenv: version `rake' not installed
在命令行中,如果我查找版本,我会看到:
rake -V
rake, version 11.2.2
rails -v
Rails 4.2.0
ruby -v
ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
但我仍然收到此错误:
bundle exec rake db:setup
Could not find rake-10.4.2 in any of the sources
Run `bundle install` to install missing gems.
什么能解决这个问题?
这更令人困惑:
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...
Installing rake 11.2.2 (was 10.4.2)
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.3
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.0
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.2
Using nokogiri 1.6.6.4
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Using loofah 2.0.3
Using rails-html-sanitizer 1.0.2
Using actionview 4.2.0
Using rack 1.6.4
Using rack-test 0.6.3
Using actionpack 4.2.0
Using globalid 0.3.6
Using activejob 4.2.0
Using mime-types 2.99
Using mail 2.6.3
Using actionmailer 4.2.0
Using activemodel 4.2.0
Using arel 6.0.3
Using activerecord 4.2.0
Using addressable 2.3.8
Using multi_xml 0.5.5
Using httparty 0.13.7
Using uuidtools 2.1.5
Using aws-sdk 1.3.9
Using bcrypt 3.1.10
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using bson 3.2.6
Using bson_ext 1.5.1
Using bundler 1.8.5
Using byebug 8.2.1
Using xpath 2.0.0
Using capybara 2.5.0
Using ffi 1.9.10
Using childprocess 0.5.8
Using climate_control 0.0.3
Using cocaine 0.5.8
Using coderay 1.1.0
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using coffee-script 2.4.1
Using thor 0.19.1
Using railties 4.2.0
Using coffee-rails 4.1.0
Using database_cleaner 1.5.1
Using orm_adapter 0.5.0
Using responders 2.1.0
Using warden 1.2.3
Using devise 3.5.2
Using diff-lcs 1.2.5
Using dotenv 2.1.0
Using dotenv-rails 2.1.0
Using factory_girl 4.5.0
Using factory_girl_rails 4.5.0
Using faker 1.4.3
Using multipart-post 2.0.0
Using faraday 0.9.2
Using sass 3.4.19
Using foundation-rails 5.5.3.2
Using geocoder 1.2.9
Using httpclient 2.6.0.1
Using icalendar 2.3.0
Using multi_json 1.11.2
Using jbuilder 2.3.2
Using jquery-rails 4.0.5
Using jwt 1.5.2
Using kgio 2.9.3
Using method_source 0.8.2
Using mimemagic 0.3.0
Using mongo 2.1.2
Using origin 2.1.1
Using mongoid 5.0.1
Using paperclip 4.3.2
Using mongoid-paperclip 0.0.10
Using oauth2 1.0.0
Using slop 3.6.0
Using pry 0.10.1
Using pry-rails 0.3.4
Using quiet_assets 1.1.0
Using sprockets 3.4.1
Using sprockets-rails 2.3.3
Using rails 4.2.0
Using rails_serve_static_assets 0.0.4
Using rails_stdout_logging 0.0.3
Using rails_12factor 0.0.3
Using raindrops 0.15.0
Using rdoc 4.2.0
Using rspec-support 3.3.0
Using rspec-core 3.3.1
Using rspec-expectations 3.3.0
Using rspec-mocks 3.3.1
Using rspec-rails 3.3.2
Using rspec_junit_formatter 0.2.2
Using rubyzip 1.1.7
Using tilt 2.0.1
Using sass-rails 5.0.4
Using sdoc 0.4.1
Using websocket 1.2.2
Using selenium-webdriver 2.48.1
Using shoulda-matchers 2.8.0
Using signet 0.7.2
Using simple_form 3.2.0
Using spring 1.4.4
Using timezone 0.5.0
Using turbolinks 2.5.3
Using uglifier 2.7.2
Using unicorn 4.9.0
Using web-console 2.2.1
Updating files in vendor/cache
* rake-11.2.2.gem
Removing outdated .gem files from vendor/cache
* rake-10.4.2.gem
Bundle updated!
bundle exec rake db:setup
Could not find rake-11.2.2 in any of the sources
Run `bundle install` to install missing gems.
bundle update rake
所以有一行说安装了rake,下一行表示它没有安装,两条线名义上都是由Bundler管理的,所以理论上这不是缓存问题。
我将此添加到Gem文件中:
gem 'rake', '10.5.0'
然后跑
bundle install
给了我:
Updating files in vendor/cache
Bundle complete! 40 Gemfile dependencies, 116 gems now installed.
Bundled gems are installed into ./vendor/cache.
然后我尝试:
bundle exec rake db:setup
我得到了:
Could not find rake-10.5.0 in any of the sources
Run `bundle install` to install missing gems.
答案 0 :(得分:-2)
你可以尝试以 sudo
的身份运行install命令,并指定rake
这样的版本:
sudo gem install rake -v '11.2.2'