]> source.dussan.org Git - redmine.git/commitdiff
Fix warning during startup: "Unresolved or ambiguous specs during Gem::Specification...
authorGo MAEDA <maeda@farend.jp>
Thu, 14 Nov 2024 09:11:04 +0000 (09:11 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 14 Nov 2024 09:11:04 +0000 (09:11 +0000)
Patch by Katsuya HIDAKA (user:hidakatsuya).

git-svn-id: https://svn.redmine.org/redmine/trunk@23269 e93f8b46-1217-0410-a6f0-8f06a7374b81

Gemfile

diff --git a/Gemfile b/Gemfile
index cd3e1d0d307efa7c82e8361f0b59b25a45b88656..28065e3d06c3c530973ccd6aade8cd2356b3a6f9 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -52,16 +52,23 @@ end
 
 # Include database gems for the adapters found in the database
 # configuration file
-require 'erb'
-require 'yaml'
 database_file = File.join(File.dirname(__FILE__), "config/database.yml")
 if File.exist?(database_file)
-  yaml_config = ERB.new(IO.read(database_file)).result
-  database_config = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(yaml_config) : YAML.load(yaml_config)
-  adapters = database_config.values.filter_map {|c| c['adapter']}.uniq
+  database_config = File.read(database_file)
+
+  # Requiring libraries in a Gemfile may cause Bundler warnings or
+  # unexpected behavior, especially if multiple gem versions are available.
+  # So, process database.yml through ERB only if it contains ERB syntax
+  # in the adapter setting. See https://www.redmine.org/issues/41749.
+  if database_config.match?(/^ *adapter: *<%=/)
+    require 'erb'
+    database_config = ERB.new(database_config).result
+  end
+
+  adapters = database_config.scan(/^ *adapter: *(.*)/).flatten.uniq
   if adapters.any?
     adapters.each do |adapter|
-      case adapter
+      case adapter.strip
       when 'mysql2'
         gem 'mysql2', '~> 0.5.0'
         gem "with_advisory_lock"