summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-02-05 01:39:04 +0000
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2019-02-05 16:54:40 +0900
commit1abe61578c59f8ff13ca61ef5adce8c133860b34 (patch)
tree814f3e5894e9552f1ca154151a8b0cc99caa2479
parentc627124526a7f01a3433263ca1668e7ffdb4a37a (diff)
downloadbundler-1abe61578c59f8ff13ca61ef5adce8c133860b34.tar.gz
Merge #6941
6941: Ignore to add bundler lib direcotry if it is same as rubylibdir r=hsbt a=hsbt ### What was the end-user problem that led to this PR? In ruby core, the bundled bundler was located same as rubylibdir. When user used the specific version of default gems like json, Bundler uses default gems under the rubylibdir, not a specific version. Fixed https://bugs.ruby-lang.org/issues/15469 ### What was your diagnosis of the problem? See the details: https://bugs.ruby-lang.org/issues/15469#note-4 ### What is your fix for the problem, implemented in this PR? I avoid adding bundler directory from RUBYLIB environmental variable Because its directory was already added $LOAD_PATH. Co-authored-by: SHIBATA Hiroshi <hsbt@ruby-lang.org> (cherry picked from commit 9cbc7dd8f77bcc12fd7e4265ebbd948f0e19b7f7)
-rw-r--r--lib/bundler/shared_helpers.rb3
-rw-r--r--spec/bundler/shared_helpers_spec.rb9
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 50214901c5..8d7c8763ed 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -3,6 +3,7 @@
require "bundler/compatibility_guard"
require "pathname"
+require "rbconfig"
require "rubygems"
require "bundler/version"
@@ -340,7 +341,7 @@ module Bundler
def set_rubylib
rubylib = (ENV["RUBYLIB"] || "").split(File::PATH_SEPARATOR)
- rubylib.unshift bundler_ruby_lib
+ rubylib.unshift bundler_ruby_lib unless RbConfig::CONFIG["rubylibdir"] == bundler_ruby_lib
Bundler::SharedHelpers.set_env "RUBYLIB", rubylib.uniq.join(File::PATH_SEPARATOR)
end
diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb
index b66c43fd92..fcac37b398 100644
--- a/spec/bundler/shared_helpers_spec.rb
+++ b/spec/bundler/shared_helpers_spec.rb
@@ -261,6 +261,15 @@ RSpec.describe Bundler::SharedHelpers do
subject.set_bundle_environment
end
+ it "ignores if bundler_ruby_lib is same as rubylibdir" do
+ allow(Bundler::SharedHelpers).to receive(:bundler_ruby_lib).and_return(RbConfig::CONFIG["rubylibdir"])
+
+ subject.set_bundle_environment
+
+ paths = (ENV["RUBYLIB"]).split(File::PATH_SEPARATOR)
+ expect(paths.count(RbConfig::CONFIG["rubylibdir"])).to eq(0)
+ end
+
it "exits if bundle path contains the unix-like path separator" do
if Gem.respond_to?(:path_separator)
allow(Gem).to receive(:path_separator).and_return(":")