Psych AliasesNotEnabled after upgrading Rails to latest version

257 views Asked by At

I had an application running on Ruby 1.9.2 and Rails 3.0.3. I upgraded Ruby to version 3.0.0 and Rails to 7.1.2. Now when I run "rails server", I have the following error message and the server is exiting:

/usr/local/rvm/gems/ruby-3.0.0/gems/psych-5.1.1.1/lib/psych/visitors/to_ruby.rb:432:in visit_Psych_Nodes_Alias': Alias parsing was not enabled. To enable it, pass aliases: truetoPsych::loadorPsych::safe_load`. (Psych::AliasesNotEnabled)

Someone posted the same question here, What is causing the 'Alias parsing was not enabled' error in Psych while upgrading Rails to 6.0.6.1 and how can it be resolved? but there was no answer.

EDIT:

It seems my error came from this call : APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env]

I apparently found a way to solve it by using this : APP_CONFIG = Rails.application.config_for(:config)

Now having another error but it's another subject...

1

There are 1 answers

0
ASX On

Apparently now you need to add aliases: true:

APP_CONFIG = YAML.load_file(
  "#{Rails.root}/config/config.yml",
  aliases: true, # <- here
)[Rails.env]