summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-12-19 17:07:48 +0000
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-12-19 18:50:45 +0100
commitd02da0d81b4c75517e41a0baa8742ffed9d77288 (patch)
tree98e36c7a90c5dc5a78560733efbbce94bce868b2
parent14af0e7417fe1fef3c521b69e0875d3ed5fed971 (diff)
downloadbundler-d02da0d81b4c75517e41a0baa8742ffed9d77288.tar.gz
Merge #7505
7505: Make sure to `require "rubygems"` explicitly r=deivid-rodriguez a=deivid-rodriguez ### What was the end-user problem that led to this PR? The problem was some setups have `--disable=gem` in `RUBYOPT`, and sometimes use `bundler` without modifying that env. ### What was your diagnosis of the problem? My diagnosis was that we shouldn't break those setups just to save a `require`. ### What is your fix for the problem, implemented in this PR? My fix is to add a `require "rubygems"` on top of the file that needs it. Fixes #7487. Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net> (cherry picked from commit eada59b3d37d6f2f1a05b2d8052a499dfb8fd222)
-rw-r--r--lib/bundler/rubygems_integration.rb2
-rw-r--r--spec/runtime/setup_spec.rb6
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 88fcd4d9e0..18da5915a5 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+require "rubygems"
+
module Bundler
class RubygemsIntegration
if defined?(Gem::Ext::Builder::CHDIR_MONITOR)
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index befc5f9d09..39240b7404 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -1344,5 +1344,11 @@ end
expect(last_command.stdboth).not_to include "FAIL"
expect(err).to include "private method `require'"
end
+
+ it "takes care of requiring rubygems" do
+ sys_exec("#{Gem.ruby} -I#{lib_dir} -e \"puts require('bundler/setup')\"", "RUBYOPT" => "--disable=gems")
+
+ expect(last_command.stdboth).to eq("true")
+ end
end
end