summaryrefslogtreecommitdiff
path: root/lib/bundler.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-14 06:01:35 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-14 06:01:35 +0000
commit68ddd4d300e9a88737c4f37af74e1a0312949b2f (patch)
tree787e1e83d76934ce039eb336995a8d5bb53a89e6 /lib/bundler.rb
parentd636809c057432e8d42abe30c6c6785eb0721d77 (diff)
Merge Bundler 2.1.0.pre.1 as developed version from upstream.
https://github.com/bundler/bundler/commit/a53709556b95a914e874b22ed2116a46b0528852 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/bundler.rb')
-rw-r--r--lib/bundler.rb75
1 files changed, 65 insertions, 10 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index cf3a289df2..f792a3bc98 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -5,7 +5,6 @@ require "bundler/compatibility_guard"
require "bundler/vendored_fileutils"
require "pathname"
require "rbconfig"
-require "thread"
require "bundler/errors"
require "bundler/environment_preserver"
@@ -119,7 +118,7 @@ module Bundler
end
def environment
- SharedHelpers.major_deprecation 3, "Bundler.environment has been removed in favor of Bundler.load"
+ SharedHelpers.major_deprecation 2, "Bundler.environment has been removed in favor of Bundler.load"
load
end
@@ -280,10 +279,19 @@ EOF
ORIGINAL_ENV.clone
end
- # @deprecated Use `original_env` instead
- # @return [Hash] Environment with all bundler-related variables removed
+ # @deprecated Use `unbundled_env` instead
def clean_env
- Bundler::SharedHelpers.major_deprecation(3, "`Bundler.clean_env` has weird edge cases, use `.original_env` instead")
+ Bundler::SharedHelpers.major_deprecation(
+ 2,
+ "`Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
+ )
+
+ unbundled_env
+ end
+
+ # @return [Hash] Environment with all bundler-related variables removed
+ def unbundled_env
env = original_env
if env.key?("BUNDLER_ORIG_MANPATH")
@@ -305,20 +313,67 @@ EOF
env
end
+ # Run block with environment present before Bundler was activated
def with_original_env
with_env(original_env) { yield }
end
+ # @deprecated Use `with_unbundled_env` instead
def with_clean_env
- with_env(clean_env) { yield }
+ Bundler::SharedHelpers.major_deprecation(
+ 2,
+ "`Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
+ )
+
+ with_env(unbundled_env) { yield }
+ end
+
+ # Run block with all bundler-related variables removed
+ def with_unbundled_env
+ with_env(unbundled_env) { yield }
+ end
+
+ # Run subcommand with the environment present before Bundler was activated
+ def original_system(*args)
+ with_original_env { Kernel.system(*args) }
end
+ # @deprecated Use `unbundled_system` instead
def clean_system(*args)
- with_clean_env { Kernel.system(*args) }
+ Bundler::SharedHelpers.major_deprecation(
+ 2,
+ "`Bundler.clean_system` has been deprecated in favor of `Bundler.unbundled_system`. " \
+ "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`"
+ )
+
+ with_env(unbundled_env) { Kernel.system(*args) }
end
+ # Run subcommand in an environment with all bundler related variables removed
+ def unbundled_system(*args)
+ with_unbundled_env { Kernel.system(*args) }
+ end
+
+ # Run a `Kernel.exec` to a subcommand with the environment present before Bundler was activated
+ def original_exec(*args)
+ with_original_env { Kernel.exec(*args) }
+ end
+
+ # @deprecated Use `unbundled_exec` instead
def clean_exec(*args)
- with_clean_env { Kernel.exec(*args) }
+ Bundler::SharedHelpers.major_deprecation(
+ 2,
+ "`Bundler.clean_exec` has been deprecated in favor of `Bundler.unbundled_exec`. " \
+ "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`"
+ )
+
+ with_env(unbundled_env) { Kernel.exec(*args) }
+ end
+
+ # Run a `Kernel.exec` to a subcommand in an environment with all bundler related variables removed
+ def unbundled_exec(*args)
+ with_env(unbundled_env) { Kernel.exec(*args) }
end
def local_platform
@@ -343,7 +398,7 @@ EOF
# system binaries. If you put '-n foo' in your .gemrc, RubyGems will
# install binstubs there instead. Unfortunately, RubyGems doesn't expose
# that directory at all, so rather than parse .gemrc ourselves, we allow
- # the directory to be set as well, via `bundle config bindir foo`.
+ # the directory to be set as well, via `bundle config set bindir foo`.
Bundler.settings[:system_bindir] || Bundler.rubygems.gem_bindir
end
@@ -523,7 +578,7 @@ EOF
rescue ScriptError, StandardError => e
msg = "There was an error while loading `#{path.basename}`: #{e.message}"
- if e.is_a?(LoadError) && RUBY_VERSION >= "1.9"
+ if e.is_a?(LoadError)
msg += "\nDoes it try to require a relative path? That's been removed in Ruby 1.9"
end