diff --git a/bundler/lib/bundler/settings.rb b/bundler/lib/bundler/settings.rb index b4fc5d86d974..6a2e0e23d3c6 100644 --- a/bundler/lib/bundler/settings.rb +++ b/bundler/lib/bundler/settings.rb @@ -97,6 +97,11 @@ def [](name) converted_value(value, name) end + def value_for(name, config) + key = key_for(name) + converted_value(config[key], name) + end + def set_command_option(key, value) if Bundler.feature_flag.forget_cli_options? temporary(key => value) @@ -206,13 +211,12 @@ def pretty_values_for(exposed_key) # for legacy reasons, in Bundler 2, we do not respect :disable_shared_gems def path configs.each do |level, config| - path_key = key_for("path") - path_system_key = key_for("path.system") - disable_shared_gems_key = key_for("disable_shared_gems") - path = config[path_key] - system_path = config[path_system_key].nil? ? (config[disable_shared_gems_key].nil? ? config[disable_shared_gems_key] : !config[disable_shared_gems_key]) : config[path_system_key] - next if path.nil? && system_path.nil? - return Path.new(converted_value(path, "path"), converted_value(system_path, "system.path")) unless !path.nil? && !system_path.nil? + path = value_for("path", config) + path_system = value_for("path.system", config) + disabled_shared_gems = value_for("disable_shared_gems", config) + next if path.nil? && path_system.nil? && disabled_shared_gems.nil? + system_path = (path_system == true) || (disabled_shared_gems == false) + return Path.new(path, system_path) unless path && system_path path = pretty_values_for(:path) path.unshift(nil, "path:") unless path.empty? system_path = pretty_values_for("path.system")