Defect #35435

Psych 4: aliases in database.yml cause Psych::BadAlias exception

Added by Pavel Rosický about 1 month ago. Updated 1 day ago.

Status:ResolvedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:


Category:Gems support
Target version:4.2.3
Resolution:Fixed Affected version:


see for details


diff --git a/Gemfile b/Gemfile
index b83cd2215..8f6bbe946 100644
--- a/Gemfile
+++ b/Gemfile
@@ -52,7 +52,8 @@ require 'erb'
 require 'yaml'
 database_file = File.join(File.dirname(__FILE__), "config/database.yml")
 if File.exist?(database_file)
-  database_config = YAML::load(
+  yaml_config =
+  database_config = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(yaml_config) : YAML.load(yaml_config)
   adapters = {|c| c['adapter']}.compact.uniq
   if adapters.any?
     adapters.each do |adapter|

without this change, Psych 4 will break aliases in config/database.yml

production: &alias
  adapter: mysql2
  database: xxx

development: *alias


Cannot load database configuration: (Psych::BadAlias)
Unknown alias: alias

Associated revisions

Revision 21059
Added by Go MAEDA 24 days ago

Psych 4: aliases in database.yml cause Psych::BadAlias exception (#35435).

Patch by Pavel Rosický.


#1 Updated by Go MAEDA 27 days ago

  • Description updated (diff)
  • Target version set to 4.1.4

Confirmed the issue by adding the following line to Gemfile.local.

gem 'psych', '~> 4.0.0'

Setting the target version to 4.1.4.

#2 Updated by Go MAEDA 26 days ago

  • Tracker changed from Patch to Defect
  • Subject changed from Psych 4 support to Psych 4: aliases in database.yml cause Psych::BadAlias exception
  • Status changed from New to Confirmed

#3 Updated by Go MAEDA 24 days ago

  • Status changed from Confirmed to Resolved
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the fix. Thank you.

#4 Updated by Alexander Meindl 24 days ago


plugin settings do not work with psych >= 4, too.

[6] Setting.plugin_redmine_messenger
  Setting Load (0.5ms)  SELECT  `settings`.* FROM `settings` WHERE `settings`.`name` = 'plugin_redmine_messenger' ORDER BY `settings`.`id` DESC LIMIT 1
Psych::DisallowedClass: Tried to load unspecified class: ActiveSupport::HashWithIndifferentAccess
from /Users/alex/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/psych-4.0.1/lib/psych/class_loader.rb:99:in `find'

The problem is caused by

Tested with multiple plugins, Redmine 4.2.1 and Ruby 2.7.3 with

gem 'psych', '~> 4.0.0'

Some plugins are already using psych >= 4, see

#5 Updated by Go MAEDA 1 day ago

  • Target version changed from 4.1.4 to 4.2.3

Also available in: Atom PDF