Database create/schema/load command fails due to error "Could not find rake-12.0.0 in any of the sources"

We just upgraded our rails application from rails 4.2.4. to 5.1.0 and of course had to make some changes in our configuration to get it up and running on our local development station and on CricleCI. Our current problem is that the build constantly fails on Circle on the ‘database’ phase.

The stack i’m using
Ruby 2.3.1, Rails 5.1.0

The exact error i’m getting
’’’
$ bundle exec rake db:create db:schema:load db:seed

Could not find rake-12.0.0 in any of the sources
Run bundle install to install missing gems.

bundle exec rake db:create db:schema:load db:seed returned exit code 7
Action failed: bundle exec rake db:create db:schema:load db:seed
’’’

Troubleshooting steps already taken
Tried several things that were found in some forums including:
Upgraded node version
Specified Rake version 12.0.0
Replace rake command with rails
Added some lines to dependencies/pre phase found in the following links: [1|https://discuss.circleci.com/t/formerly-passed-tests-failed-due-to-missing-rake-gem/10635],[2|https://discuss.circleci.com/t/formerly-passing-build-now-fails/9590/5]

Any recent changes either in the codebase or the stack
None except upgrading to rails 5.1.0

What happens when you run the tests locally
Fails due to a different reason, probably unrelated
’’‘
rake aborted!
ActiveRecord::NoEnvironmentInSchemaError:
’’'
What is supposed to happen when your build runs
Database phase should complete successfully and then the testing phase should begin (with test either failing or succeeding - we are still stuck in the database phase though)

Circle.yml file (indentation is correct, just isn’t displayed properly)
’’‘
machine:
environment:
APIARY_API_KEY: "123…abc"
ruby:
version: 2.3.1
node:
version: 6.0.0
dependencies:
cache_directories:
- ~/.cache/yarn
override:
- yarn
pre:
- npm install -g dredd@stable
- gem install apiaryio
- pip install dredd_hooks
database:
override:
- bundle exec rake db:create db:schema:load db:seed
test:
override:
- yarn test
pre:
- apiary fetch --api-name=abc…123 --output=api-description.yml
- dredd
deployment:
staging:
branch: master
commands:
- “[[ ! -s “$(git rev-parse --git-dir)/shallow” ]] || git fetch --unshallow”
- git push git@heroku.com:abc…def.git $CIRCLE_SHA1:master
- heroku run rake db:migrate db:seed --app abc…def
’’’

2 Likes

I was able to resolve this error for myself by running,

bundle update rake

in my project directory, then adding the following to my circle.yml file:

database:
  override:
    - bundle install
    - bundle exec rake db:create db:schema:load db:seed