Psych::BadAlias: Unknown alias: default
panteo opened this issue · 4 comments
panteo commented
Steps to reproduce
- Create a blank Rails app
- Configure it to use PostgreSQL and this gem
- Create the database with
bin/rails db:create
- Run
bin/rails pg_extras:diagnose
Here it is a config/database.yml
example to reproduce the issue:
default: &default
adapter: postgresql
host: localhost
encoding: unicode
password: password
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: user
development:
<<: *default
database: rails_development
test:
<<: *default
database: rails_test
production:
<<: *default
database: rails
Expected behavior
Actual behavior
$ bin/rails pg_extras:diagnose
rails aborted!
Psych::BadAlias: Unknown alias: default
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rails-pg-extras-4.0.1/lib/rails_pg_extras/tasks/all.rake:11:in `block (2 levels) in <main>'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `each'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `invoke_prerequisites'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/command.rb:51:in `invoke'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/commands.rb:18:in `<main>'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/workspaces/rails-7/.bundle/ruby/3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
Tasks: TOP => pg_extras:diagnose => pg_extras:establish_connection
(See full trace by running task with --trace)
System configuration
Rails version: 7.0.2.3
Ruby version: 3.1.1
pawurb commented
Is it still an issue? I cannot reproduce.
panteo commented
Yes, it is.
I have updated to the 4.1.0 version, but the issue is still present.
Did you use a yaml config with aliases for your database?
If not, please, try with something like the config in the description of the issue.
Here it is how has been solved elsewhere: https://www.redmine.org/issues/36226
I tryed the fix locally and it works.
pawurb commented
I've managed to reproduce and fix. Next release will include this change. Thanks!
panteo commented
Thank you ;-)