title: Why doesn't "bundle exec" see that I have rake installed?
body: <p>I've been reading StackOverflow and trying to deal with this error for 2 hours now: </p>
  
  <pre class="lang-bash prettyprint-override"><code>bundle exec rake db:setup
  Could not find rake-10.4.2 in any of the sources
  Run `bundle install` to install missing gems.
  </code></pre>
  
  <p>I followed the advice here, to no avail:</p>
  
  <p><a href="https://stackoverflow.com/questions/27879119/rails-s-could-not-find-rake-10-4-2-in-any-of-the-sources-bundlergemnotfound">rails s: Could not find rake-10.4.2 in any of the sources (Bundler::GemNotFound)</a></p>
  
  <p>also:</p>
  
  <p><a href="https://stackoverflow.com/questions/18978002/could-not-find-rake-with-bundle-exec">Could not find rake with bundle exec</a></p>
  
  <p>So I did: </p>
  
  <pre class="lang-bash prettyprint-override"><code>gem uninstall rake
  gem install rake
  </code></pre>
  
  <p>And, following the other StackOverflow articles I read, I tried: </p>
  
  <pre class="lang-bash prettyprint-override"><code>rbenv install 2.3.1                   
  Downloading ruby-2.3.1.tar.bz2...
  -&gt; 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
  </code></pre>
  
  <p>At the command line, if I look for versions, I see: </p>
  
  <pre class="lang-bash prettyprint-override"><code>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]
  </code></pre>
  
  <p>but I still get this error:</p>
  
  <pre class="lang-bash prettyprint-override"><code>bundle exec rake db:setup   
  Could not find rake-10.4.2 in any of the sources
  Run `bundle install` to install missing gems.
  </code></pre>
  
  <p>What would fix this? </p>
  
  <h2>Update 1</h2>
  
  <p>This is even more confusing:</p>
  
  <pre class="lang-bash prettyprint-override"><code>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    
  </code></pre>
  
  <p>So one line says that rake is installed, and the next line says that it is not installed, and both lines are nominally being managed by Bundler, so in theory this can not be a cache problem.</p>
  
  <h2>Update 2</h2>
  
  <p>I added this to the Gem file: </p>
  
  <pre class="lang-bash prettyprint-override"><code>gem 'rake', '10.5.0'
  </code></pre>
  
  <p>And then ran </p>
  
  <pre class="lang-bash prettyprint-override"><code>bundle install
  </code></pre>
  
  <p>which gives me: </p>
  
  <pre class="lang-bash prettyprint-override"><code>Updating files in vendor/cache
  Bundle complete! 40 Gemfile dependencies, 116 gems now installed.
  Bundled gems are installed into ./vendor/cache.
  </code></pre>
  
  <p>So then I try:</p>
  
  <pre class="lang-bash prettyprint-override"><code>bundle exec rake db:setup  
  </code></pre>
  
  <p>and I get: </p>
  
  <pre><code>Could not find rake-10.5.0 in any of the sources
  Run `bundle install` to install missing gems.
  </code></pre>