aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2017-01-15 20:15:45 +0000
committerThe Bundler Bot <bot@bundler.io>2017-01-15 20:15:45 +0000
commitb72d6af45a6bc55327c8cdd127b79e7b1fa8ab79 (patch)
treecef63fc403ec6d46814a00c71006a55227dd60bd /lib
parent50411ca2f5867dd46b42244c3ef9c2fddf25f85d (diff)
parente67df19ebd92d25bc1e8960ce0985a61bc5c997e (diff)
downloadbundler-b72d6af45a6bc55327c8cdd127b79e7b1fa8ab79.tar.gz
Auto merge of #5327 - bundler:seg-outdated-bundler-message, r=indirect
[CLI] Warn when running an outdated bundler version Closes https://github.com/bundler/bundler/issues/4683. The `send`s are super hacky but ¯\_(ツ)_/¯
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli.rb22
-rw-r--r--lib/bundler/settings.rb3
2 files changed, 24 insertions, 1 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index eb9362a5..a70d66f2 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -13,6 +13,7 @@ module Bundler
Bundler.ui = UI::Shell.new
raise e
ensure
+ warn_on_outdated_bundler
Bundler::SharedHelpers.print_major_deprecations!
end
@@ -579,5 +580,26 @@ module Bundler
command.reject!(&:empty?)
Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler::VERSION}"
end
+
+ def self.warn_on_outdated_bundler
+ return if Bundler.settings[:disable_version_check]
+
+ latest = Fetcher::CompactIndex.
+ new(nil, Source::Rubygems::Remote.new(URI("https://rubygems.org")), nil).
+ send(:compact_index_client).
+ instance_variable_get(:@cache).
+ dependencies("bundler").
+ map {|d| Gem::Version.new(d.first) }.
+ max
+ return unless latest
+
+ current = Gem::Version.new(VERSION)
+ return if current >= latest
+
+ Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\nTo update, run `gem install bundler#{" --pre" if latest.prerelease?}`"
+ rescue
+ nil
+ end
+ private_class_method :warn_on_outdated_bundler
end
end
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index 35ad17ae..b2136384 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -11,6 +11,8 @@ module Bundler
disable_exec_load
disable_local_branch_check
disable_shared_gems
+ disable_version_check
+ force_ruby_platform
frozen
gem.coc
gem.mit
@@ -18,7 +20,6 @@ module Bundler
major_deprecations
no_install
no_prune
- force_ruby_platform
only_update_to_newer_versions
plugins
silence_root_warning