'rake db:create -> stack level too deep, couldn't create database, please check your configuration

I have an old app dating all the way back to Rails 2. We are currently upgrading it.

The database is refusing to create with the settings below. What could be going on?

When I run rake db:create:

Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Running cron.rake
Running roles.rake
begin Rakefile
development
stack level too deep
Couldn't create 'project_dev' database. Please check your configuration.
rake aborted!
SystemStackError: stack level too deep
/Users/ss/.rvm/gems/ruby-3.1.0/gems/activesupport-7.0.2.2/lib/active_support/core_ext/object/instance_variables.rb:15:in `block in instance_values'
/Users/ss/.rvm/gems/ruby-3.1.0/gems/activesupport-7.0.2.2/lib/active_support/core_ext/object/instance_variables.rb:15:in `map'
/Users/ss/.rvm/gems/ruby-3.1.0/gems/activesupport-7.0.2.2/lib/active_support/core_ext/object/instance_variables.rb:15:in `instance_values'
/Users/ss/.rvm/gems/ruby-3.1.0/gems/activesupport-7.0.2.2/lib/active_support/core_ext/object/json.rb:63:in `as_json'
/Users/ss/.rvm/gems/ruby-3.1.0/gems/activesupport-7.0.2.2/lib/active_support/core_ext/object/json.rb:180:in `block in as_json'
/Users/ss/.rvm/gems/ruby-3.1.0/gems/activesupport-7.0.2.2/lib/active_support/core_ext/object/json.rb:179:in `each'
/Users/ss/.rvm/gems/ruby-3.1.0/gems/activesupport-7.0.2.2/lib/active_support/core_ext/object/json.rb:179:in `as_json'
/Users/ss/.rvm/gems/ruby-3.1.0/gems/activesupport-7.0.2.2/lib/active_support/core_ext/object/json.rb:63:in `as_json'
/Users/ss/.rvm/gems/ruby-3.1.0/gems/activesupport-7.0.2.2/lib/active_support/core_ext/object/json.rb:180:in `block in as_json'
/Users/ss/.rvm/gems/ruby-3.1.0/gems/activesupport-7.0.2.2/lib/active_support/core_ext/object/json.rb:179:in `each'
/Users/ss/.rvm/gems/ruby-3.1.0/gems/activesupport-7.0.2.2/lib/active_support/core_ext/object/json.rb:179:in `as_json'
... repeats many times ...

database.yml:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: <%= Rails.application.credentials.database[:username] %>
  password: <%= Rails.application.credentials.database[:password] %>

development:
  <<: *default
  database: project_dev
  host: localhost

test:
  <<: *default
  database: project_test

psql postgres:

postgres=#  \du

  Role name   |                         Attributes                         | Member of 
--------------+------------------------------------------------------------+-----------
 applyco      | Superuser                                                  | {}

postgres=#  \list
(List does not include project_dev or project_test).


Solution 1:[1]

Remove the gem 'meta_request' to fix the issue.

Source: https://github.com/rails/rails/issues/40781#issuecomment-742807721

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sscirrus