Unable to `rake db:structure:load` without breaking bundle cache



I have not been able to get my build past rake db:structure:load without adding a line to my config to pull in some stuff via apt-get. However, doing this seems to cause my bundle cache to not be used.

Without the apt-get line, I get the error:

** Execute db:structure:load
rake aborted!
failed to execute:
psql -q -f /home/circleci/midroll/db/structure.sql myapp_test

Please check the output above for any errors and make sure that `psql` is installed in your PATH and has proper permissions.

Any ideas? Including config.yml below:

version: 2
    working_directory: ~/myapp
      - image: circleci/ruby:2.3.3-node
          RAILS_ENV: test
          RACK_ENV: test
          PG_HOST: localhost
          PGUSER: ubuntu
      - image: postgres:9.4.7
          POSTGRES_USER: ubuntu
          POSTGRES_DB: myapp_test
      - image: redis:3.2.6
          POSTGRES_USER: root

      - checkout
      - run: sudo apt-get update -qq && sudo apt-get install -y build-essential nodejs redis-tools postgresql

      # Restore bundle cache
      - type: cache-restore
        key: myapp-{{ checksum "Gemfile.lock" }}

      # Bundle install dependencies
      - run: bundle install --path vendor/bundle

      # Store bundle cache
      - type: cache-save
        key: myapp-{{ checksum "Gemfile.lock" }}
          - vendor/bundle

      # Database setup
      - run: bundle exec rake db:create
      - run: bundle exec rake db:structure:load --trace

      # Run rspec in parallel
      - type: shell
        command: |
          bundle exec rspec --profile 10 \
                            --out /tmp/test-results/rspec.xml \
                            --format progress \
                            $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)

      # Save artifacts
      - type: store_test_results
        path: /tmp/test-results


That is all 100% correct. You are using psql and we’re not including it on the image at this time. You can definitely build your own image, though. Just extend the image in your config right now, install those packages, commit & push it to Docker Hub (or the registry of your choosing).


Very helpful, thanks! :slight_smile:


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.