summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli.rb7
-rw-r--r--lib/bundler/cli/package.rb2
-rw-r--r--lib/bundler/templates/Executable.bundler35
3 files changed, 27 insertions, 17 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index c7af38bcaf..2f35b83c36 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -411,9 +411,10 @@ module Bundler
end
desc "#{Bundler.feature_flag.bundler_3_mode? ? :cache : :package} [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
- method_option "all", :type => :boolean,
- :default => Bundler.feature_flag.cache_all?,
- :banner => "Include all sources (including path and git)."
+ unless Bundler.feature_flag.cache_all?
+ method_option "all", :type => :boolean,
+ :banner => "Include all sources (including path and git)."
+ end
method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one"
method_option "cache-path", :type => :string, :banner =>
"Specify a different cache path than the default (vendor/cache)."
diff --git a/lib/bundler/cli/package.rb b/lib/bundler/cli/package.rb
index 731677b4ec..b31b67776d 100644
--- a/lib/bundler/cli/package.rb
+++ b/lib/bundler/cli/package.rb
@@ -34,7 +34,7 @@ module Bundler
end
def setup_cache_all
- all = options.fetch(:all, Bundler.feature_flag.bundler_3_mode? || nil)
+ all = options.fetch(:all, Bundler.feature_flag.cache_all? || nil)
Bundler.settings.set_command_option_if_given :cache_all, all
diff --git a/lib/bundler/templates/Executable.bundler b/lib/bundler/templates/Executable.bundler
index 3adac41e74..69f26bb9c0 100644
--- a/lib/bundler/templates/Executable.bundler
+++ b/lib/bundler/templates/Executable.bundler
@@ -31,7 +31,7 @@ m = Module.new do
bundler_version = a
end
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
- bundler_version = $1 || ">= 0.a"
+ bundler_version = $1
update_index = i
end
bundler_version
@@ -61,32 +61,41 @@ m = Module.new do
end
def bundler_version
- @bundler_version ||= begin
+ @bundler_version ||=
env_var_version || cli_arg_version ||
- lockfile_version || "#{Gem::Requirement.default}.a"
- end
+ lockfile_version
+ end
+
+ def bundler_requirement
+ return "#{Gem::Requirement.default}.a" unless bundler_version
+
+ bundler_gem_version = Gem::Version.new(bundler_version)
+
+ requirement = bundler_gem_version.approximate_recommendation
+
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
+
+ requirement += ".a" if bundler_gem_version.prerelease?
+
+ requirement
end
def load_bundler!
ENV["BUNDLE_GEMFILE"] ||= gemfile
- # must dup string for RG < 1.8 compatibility
- activate_bundler(bundler_version.dup)
+ activate_bundler
end
- def activate_bundler(bundler_version)
- if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
- bundler_version = "< 2"
- end
+ def activate_bundler
gem_error = activation_error_handling do
- gem "bundler", bundler_version
+ gem "bundler", bundler_requirement
end
return if gem_error.nil?
require_error = activation_error_handling do
require "bundler/version"
end
- return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
- warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
exit 42
end