summaryrefslogtreecommitdiff
path: root/lib/bundler/shared_helpers.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-06-01 12:49:40 +0300
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-06-09 12:44:10 +0900
commit8f37629519ad330032a38ac0e871b2912ed38a1b (patch)
treebb0529b77583d47993d8b0d608d68896aa3a5298 /lib/bundler/shared_helpers.rb
parent66508992483ae5d77b56a98427c50c772341c0ac (diff)
Merge bundler master from upstream.
Pick from 8dd59e3ba97eb80a599f8149f31bf40773b69dc0
Diffstat (limited to 'lib/bundler/shared_helpers.rb')
-rw-r--r--lib/bundler/shared_helpers.rb43
1 files changed, 16 insertions, 27 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 1b703c5cbc..d259f20e6b 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -1,15 +1,15 @@
# frozen_string_literal: true
-require "bundler/compatibility_guard"
+require_relative "compatibility_guard"
require "pathname"
require "rbconfig"
require "rubygems"
-require "bundler/version"
-require "bundler/constants"
-require "bundler/rubygems_integration"
-require "bundler/current_ruby"
+require_relative "version"
+require_relative "constants"
+require_relative "rubygems_integration"
+require_relative "current_ruby"
module Bundler
module SharedHelpers
@@ -103,9 +103,7 @@ module Bundler
#
# @see {Bundler::PermissionError}
def filesystem_access(path, action = :write, &block)
- # Use block.call instead of yield because of a bug in Ruby 2.2.2
- # See https://github.com/bundler/bundler/issues/5341 for details
- block.call(path.dup.untaint)
+ yield(path.dup.untaint)
rescue Errno::EACCES
raise PermissionError.new(path, action)
rescue Errno::EAGAIN
@@ -132,7 +130,7 @@ module Bundler
def major_deprecation(major_version, message)
bundler_major_version = Bundler.bundler_major_version
if bundler_major_version > major_version
- require "bundler/errors"
+ require_relative "errors"
raise DeprecatedError, "[REMOVED] #{message}"
end
@@ -289,20 +287,10 @@ module Bundler
public :set_env
def set_bundle_variables
- begin
- exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
- unless File.exist?(exe_file)
- exe_file = File.expand_path("../../../exe/bundle", __FILE__)
- end
- Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
- rescue Gem::GemNotFoundException
- exe_file = File.expand_path("../../../exe/bundle", __FILE__)
- # for Ruby core repository
- exe_file = File.expand_path("../../../../bin/bundle", __FILE__) unless File.exist?(exe_file)
- Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
- end
-
- # Set BUNDLE_GEMFILE
+ exe_file = File.expand_path("../../../exe/bundle", __FILE__)
+ # for Ruby core repository
+ exe_file = File.expand_path("../../../../bin/bundle", __FILE__) unless File.exist?(exe_file)
+ Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile(:order_matters).to_s
Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
end
@@ -316,8 +304,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
@@ -351,9 +340,9 @@ module Bundler
end
def prints_major_deprecations?
- require "bundler"
+ require_relative "../bundler"
return false if Bundler.settings[:silence_deprecations]
- require "bundler/deprecate"
+ require_relative "deprecate"
return false if Bundler::Deprecate.skip
true
end