Skip to content

Commit

Permalink
Prioritize path.system over path when it makes sense
Browse files Browse the repository at this point in the history
If `path.system` is configured locally, and `path` is configured
globally, gems should be installed to `path.system`.
  • Loading branch information
deivid-rodriguez committed Sep 8, 2020
1 parent 85d8ac8 commit 418998c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 8 additions & 6 deletions bundler/lib/bundler/settings.rb
Expand Up @@ -195,14 +195,16 @@ def pretty_values_for(exposed_key)

# for legacy reasons, in Bundler 2, we do not respect :disable_shared_gems
def path
key = key_for(:path)
path = ENV[key] || @global_config[key]
if path && !@temporary.key?(key) && !@local_config.key?(key)
return Path.new(path, false)
configs.each do |_level, settings|
path = value_for("path", settings)
path_system = value_for("path.system", settings)
disabled_shared_gems = value_for("disable_shared_gems", settings)
next if path.nil? && path_system.nil? && disabled_shared_gems.nil?
system_path = path_system || (disabled_shared_gems == false)
return Path.new(path, system_path)
end

system_path = self["path.system"] || (self[:disable_shared_gems] == false)
Path.new(self[:path], system_path)
Path.new(nil, false)
end

Path = Struct.new(:explicit_path, :system_path) do
Expand Down
8 changes: 8 additions & 0 deletions bundler/spec/install/path_spec.rb
Expand Up @@ -19,6 +19,14 @@
expect(the_bundle).to include_gems "rack 1.0.0"
end

it "uses system gems with `path.system` configured with more priority than `path`" do
bundle "config --local path.system true"
bundle "config --global path vendor/bundle"
bundle :install
run "require 'rack'", :raise_on_error => false
expect(out).to include("FAIL")
end

it "handles paths with regex characters in them" do
dir = bundled_app("bun++dle")
dir.mkpath
Expand Down

0 comments on commit 418998c

Please sign in to comment.