URI::InvalidComponentError: bad component(expected absolute path component): _cache (URI::InvalidComponentError)

Getting the following error in my github actions on push:

Run bin/rails db:test:prepare test

bin/rails aborted!

URI::InvalidComponentError: bad component(expected absolute path component): _cache (URI::InvalidComponentError)

My ci.yml is as follows for run tests:

      - name: Run tests
        env:
          RAILS_ENV: test
          DATABASE_URL: postgres://postgres:postgres@localhost:5432
          # REDIS_URL: redis://localhost:6379/0
        run: bin/rails db:test:prepare test

I have an API only rails app if that helps? First time doing this.

Found this post about it:

Changing my database.yml to the following made it pass, though I’m not sure I really understand:

production:
  primary: &primary_production
    <<: *default
    database: waldo_api_production
    username: waldo_api
    password: <%= ENV["WALDO_API_DATABASE_PASSWORD"] %>
    url: <%= ENV["DATABASE_URL"] %>
  cache:
    <<: *primary_production
    database: waldo_api_production_cache
    migrations_paths: db/cache_migrate
    url: <%= URI.parse(ENV["DATABASE_URL"]).tap { |url| url.path += "_cache" } if ENV["DATABASE_URL"] && Rails.env.production? %>
  queue:
    <<: *primary_production
    database: waldo_api_production_queue
    migrations_paths: db/queue_migrate
    url: <%= URI.parse(ENV["DATABASE_URL"]).tap { |url| url.path += "_queue" } if ENV["DATABASE_URL"] && Rails.env.production? %>
  cable:
    <<: *primary_production
    database: waldo_api_production_cable
    migrations_paths: db/cable_migrate
    url: <%= URI.parse(ENV["DATABASE_URL"]).tap { |url| url.path += "_cable" } if ENV["DATABASE_URL"] && Rails.env.production? %>

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