aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler/shared_helpers.rb
diff options
context:
space:
mode:
authorJacopo <beschi.jacopo@gmail.com>2023-09-26 10:13:31 +0200
committergit <svn-admin@ruby-lang.org>2023-10-09 11:54:10 +0000
commitf44cee90480c103d911836f92a4e0e20c0eca1e5 (patch)
tree3c7d1bda2659ccc43ad46db3def9be3e53dd0eef /lib/bundler/shared_helpers.rb
parent0fdee133fccbd34af31f5f4ca530838920d8fc06 (diff)
downloadruby-f44cee90480c103d911836f92a4e0e20c0eca1e5.tar.gz
[rubygems/rubygems] Avoid duplicates -rbundler/setup in RUBYOPT with Ruby preview
When using a Ruby preview the require path of `bundler/setup` is similar to `-r/opt/ruby3.3.0-preview2/lib/ruby/3.3.0+0/bundler/setup`. The special character `+` in the string makes the Regexp fail, leading to multiple addition of the same require statement each time `set_rubyopt` is called (e.g. server reloading). Escaping the characters in the string esure a correct match with all the different Ruby versions. https://github.com/rubygems/rubygems/commit/dd43dfa709
Diffstat (limited to 'lib/bundler/shared_helpers.rb')
-rw-r--r--lib/bundler/shared_helpers.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 165982ad0a..5196243949 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -312,7 +312,7 @@ module Bundler
def set_rubyopt
rubyopt = [ENV["RUBYOPT"]].compact
setup_require = "-r#{File.expand_path("setup", __dir__)}"
- return if !rubyopt.empty? && rubyopt.first =~ /#{setup_require}/
+ return if !rubyopt.empty? && rubyopt.first =~ /#{Regexp.escape(setup_require)}/
rubyopt.unshift setup_require
Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ")
end