Rails 升级到 Rails 5.2 之后,Cannot load `Rails.application.database_configuration

bill997603 · December 25, 2021 · Last by lijunwei replied at December 26, 2021 · 644 hits

我从 5.1.6 升级到 5.2 之后,执行 rails c,控制台返回

/Users/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/psych-4.0.3/lib/psych/visitors/to_ruby.rb:430:in visit_Psych_Nodes_Alias': Cannot loadRails.application.database_configuration`: (Psych::BadAlias) Unknown alias: default

我的 database.yml

default: &default
  adapter: postgresql
  encoding: unicode
  pool: 50
  username: root
  password:
  host: localhost

development:
  <<: *default
  database: a_production

test:
  <<: *default
  database: a_test<%= ENV['TEST_ENV_NUMBER'] %>

production:
  <<: *default
  database: a_production

我想到两个思路

  1. 把别名直接替换成原始的值试一下能不能启动,这个方法应该能暂时能绕过 yaml 的别名解析,
  2. 可能是 gem 'psych' 版本不兼容了,更新一下试试(https://www.redmine.org/issues/35435
bill997603 closed this topic. 27 Dec 10:12
You need to Sign in before reply, if you don't have an account, please Sign up first.