summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-05-08 13:41:03 +0200
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-05-12 09:25:06 -0400
commita5da088a6d8aa2bb14d5007dc7f70b25a50d79d7 (patch)
treef06982e7259c91ca4205ef8407068a93bad2e393
parentb874d63cd3cfdd2d52a5e6fa849c8b7a3f116d1b (diff)
downloadbundler-a5da088a6d8aa2bb14d5007dc7f70b25a50d79d7.tar.gz
Setup rubyopt to require bundler absolutely
This way, we will never leak to a different bundler copy.
-rw-r--r--lib/bundler/shared_helpers.rb5
-rw-r--r--spec/bundler/shared_helpers_spec.rb2
-rw-r--r--spec/commands/exec_spec.rb2
3 files changed, 5 insertions, 4 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index e56a44a559..da2a384d29 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -291,8 +291,9 @@ module Bundler
def set_rubyopt
rubyopt = [ENV["RUBYOPT"]].compact
- return if !rubyopt.empty? && rubyopt.first =~ %r{-rbundler/setup}
- rubyopt.unshift %(-rbundler/setup)
+ setup_require = "-r#{File.expand_path("setup", __dir__)}"
+ return if !rubyopt.empty? && rubyopt.first =~ /#{setup_require}/
+ rubyopt.unshift %(#{setup_require})
Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ")
end
diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb
index 7cd6aa7566..a9bf67b0d5 100644
--- a/spec/bundler/shared_helpers_spec.rb
+++ b/spec/bundler/shared_helpers_spec.rb
@@ -237,7 +237,7 @@ RSpec.describe Bundler::SharedHelpers do
shared_examples_for "ENV['RUBYOPT'] gets set correctly" do
it "ensures -rbundler/setup is at the beginning of ENV['RUBYOPT']" do
subject.set_bundle_environment
- expect(ENV["RUBYOPT"].split(" ")).to start_with("-rbundler/setup")
+ expect(ENV["RUBYOPT"].split(" ")).to start_with("-r#{File.expand_path("../../lib/bundler/setup", __dir__)}")
end
end
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index 39e27e94f2..8f49c576b5 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -279,7 +279,7 @@ RSpec.describe "bundle exec" do
G
rubyopt = ENV["RUBYOPT"]
- rubyopt = "-rbundler/setup #{rubyopt}"
+ rubyopt = "-r#{File.expand_path("../../lib/bundler/setup", __dir__)} #{rubyopt}"
bundle "exec 'echo $RUBYOPT'"
expect(out).to have_rubyopts(rubyopt)