diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 5f70ca1e9..559e4b164 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -130,10 +130,24 @@ module Vagrant # initialization. The cache file will cause this to mostly be a no-op # most of the time. @checkpoint_thr = Thread.new do - @checkpoint_result = Checkpoint.check( + Thread.current[:result] = nil + + # If we disabled checkpoint via env var, don't run this + if ENV["VAGRANT_CHECKPOINT_DISABLE"].to_s != "" + next + end + + # If we disabled state and knowing what alerts we've seen, then + # disable the signature file. + signature_file = @data_dir.join("checkpoint_signature") + if ENV["VAGRANT_CHECKPOINT_NO_STATE"].to_s != "" + signature_file = nil + end + + Thread.current[:result] = Checkpoint.check( product: "vagrant", version: VERSION, - signature_file: @data_dir.join("checkpoint_signature"), + signature_file: signature_file, cache_file: @data_dir.join("checkpoint_cache"), ) end @@ -263,7 +277,7 @@ module Vagrant # @return [Hash] def checkpoint @checkpoint_thr.join - return @checkpoint_result + return @checkpoint_thr[:result] end # Makes a call to the CLI with the given arguments as if they diff --git a/lib/vagrant/shared_helpers.rb b/lib/vagrant/shared_helpers.rb index 5521d43e9..c2c52ae10 100644 --- a/lib/vagrant/shared_helpers.rb +++ b/lib/vagrant/shared_helpers.rb @@ -38,25 +38,6 @@ module Vagrant ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"] end - # Returns the latest version of Vagrant that is available. - # - # This makes an HTTP call. - # - # @return [String] - def self.latest_version - # Lazy-require this so that the overhead of this file is low - require "vagrant/util/downloader" - - tf = Tempfile.new("vagrant") - tf.close - url = "http://www.vagrantup.com/latest-version.json" - Vagrant::Util::Downloader.new(url, tf.path).download! - data = JSON.parse(File.read(tf.path)) - data["version"] - ensure - tf.unlink if tf - end - # This returns whether or not 3rd party plugins should be loaded. # # @return [Boolean] diff --git a/plugins/commands/version/command.rb b/plugins/commands/version/command.rb index 100082440..873b202c9 100644 --- a/plugins/commands/version/command.rb +++ b/plugins/commands/version/command.rb @@ -22,8 +22,15 @@ module VagrantPlugins "vagrant.version_current", version: Vagrant::VERSION)) @env.ui.machine("version-installed", Vagrant::VERSION) - # Load the latest version - latest = Vagrant.latest_version + # Load the latest information + cp = @env.checkpoint + if !cp + @env.ui.output("\n"+I18n.t( + "vagrant.version_no_checkpoint")) + return 0 + end + + latest = cp["current_version"] # Output latest version @env.ui.output(I18n.t( diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 050fe2972..4be7a92e7 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -229,6 +229,9 @@ en: Latest Version: %{version} version_latest_installed: |- You're running an up-to-date version of Vagrant! + version_no_checkpoint: |- + Vagrant was unable to check for the latest version of Vagrant. + Please check manually at http://www.vagrantup.com version_upgrade_howto: |- To upgrade to the latest version, visit the downloads page and download and install the latest version of Vagrant from the URL