Warn if Vagrant is run outside of installers

This commit is contained in:
Mitchell Hashimoto 2013-01-28 13:39:56 -08:00
parent b8429d5454
commit 0d27cd5bcb
3 changed files with 18 additions and 0 deletions

View File

@ -41,6 +41,9 @@ begin
logger.debug("Creating Vagrant environment")
env = Vagrant::Environment.new(opts)
# If we're not in the installer, warn.
env.ui.warn(I18n.t("vagrant.general.not_in_installer")) if !Vagrant.in_installer?
# Execute the CLI interface, and exit with the proper error code
exit(env.cli(ARGV))
rescue Vagrant::Errors::VagrantError => e

View File

@ -103,6 +103,14 @@ module Vagrant
c.register([:"2", :provisioner]) { Plugin::V2::Provisioner }
end
# This returns a true/false showing whether we're running from the
# environment setup by the Vagrant installers.
#
# @return [Boolean]
def self.in_installer?
!!ENV["VAGRANT_INSTALLER_ENV"]
end
# The source root is the path to the root directory of
# the Vagrant gem.
def self.source_root

View File

@ -18,6 +18,13 @@ en:
Old: %{old}
New: %{new}
not_in_installer: |-
You appear to be running Vagrant outside of the official installers.
Note that the installers are what ensure that Vagrant has all required
dependencies, and Vagrant assumes that these dependencies exist. By
running outside of the installer environment, Vagrant may not function
properly. To remove this warning, install Vagrant using one of the
official packages from vagrantup.com.
upgraded_v1_dotfile: |-
A Vagrant 1.0.x state file was found for this environment. Vagrant has
gone ahead and auto-upgraded this to the latest format. Everything