warn if running in a bundler env, don't load plugins
This commit is contained in:
parent
f2c6175d16
commit
8adef9c15f
15
bin/vagrant
15
bin/vagrant
|
@ -105,21 +105,8 @@ begin
|
||||||
env = Vagrant::Environment.new(opts)
|
env = Vagrant::Environment.new(opts)
|
||||||
|
|
||||||
if !Vagrant.in_installer?
|
if !Vagrant.in_installer?
|
||||||
warned = false
|
|
||||||
|
|
||||||
# If we're in a bundler environment, we assume it is for plugin
|
|
||||||
# development and will let the user know that.
|
|
||||||
if defined?(Bundler)
|
|
||||||
require 'bundler/shared_helpers'
|
|
||||||
if Bundler::SharedHelpers.in_bundle?
|
|
||||||
env.ui.warn(I18n.t("vagrant.general.in_bundler"))
|
|
||||||
env.ui.warn("")
|
|
||||||
warned = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# If we're not in the installer, warn.
|
# If we're not in the installer, warn.
|
||||||
env.ui.warn(I18n.t("vagrant.general.not_in_installer")) if !warned
|
env.ui.warn(I18n.t("vagrant.general.not_in_installer"))
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -1,17 +1,29 @@
|
||||||
# This file is load before RubyGems are loaded, and allow us to actually
|
# This file is load before RubyGems are loaded, and allow us to actually
|
||||||
# resolve plugin dependencies and load the proper versions of everything.
|
# resolve plugin dependencies and load the proper versions of everything.
|
||||||
|
|
||||||
if defined?(Vagrant)
|
|
||||||
raise "vagrant is somehow already loaded. bug."
|
|
||||||
end
|
|
||||||
|
|
||||||
ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"] = "/Applications/Vagrant/embedded"
|
ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"] = "/Applications/Vagrant/embedded"
|
||||||
|
|
||||||
# Initialize Bundler before we load _any_ RubyGems.
|
if defined?(Bundler)
|
||||||
require_relative "vagrant/bundler"
|
require "bundler/shared_helpers"
|
||||||
require_relative "vagrant/plugin_manager"
|
if Bundler::SharedHelpers.in_bundle?
|
||||||
Vagrant::Bundler.instance.init!(Vagrant::PluginManager.plugins)
|
puts "Vagrant appears to be running in a Bundler environment. Plugins"
|
||||||
|
puts "will not be loaded and plugin commands are disabled."
|
||||||
|
puts
|
||||||
|
ENV["VAGRANT_NO_PLUGINS"] = "1"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Initialize Vagrant first, then load the remaining dependencies
|
require_relative "vagrant/shared_helpers"
|
||||||
|
|
||||||
|
if Vagrant.plugins_enabled?
|
||||||
|
# Initialize Bundler before we load _any_ RubyGems.
|
||||||
|
require_relative "vagrant/bundler"
|
||||||
|
require_relative "vagrant/plugin_manager"
|
||||||
|
Vagrant::Bundler.instance.init!(Vagrant::PluginManager.plugins)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Initialize Vagrant now that our Gem paths are setup
|
||||||
require "vagrant/init"
|
require "vagrant/init"
|
||||||
Bundler.require(:default)
|
|
||||||
|
# If we have plugins enabled, then load those
|
||||||
|
Bundler.require(:default) if Vagrant.plugins_enabled?
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
|
|
||||||
require_relative "paths"
|
require_relative "shared_helpers"
|
||||||
require_relative "version"
|
require_relative "version"
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
|
@ -21,7 +21,9 @@ module Vagrant
|
||||||
@configfile = Tempfile.new("vagrant-bundler-config")
|
@configfile = Tempfile.new("vagrant-bundler-config")
|
||||||
@configfile.close
|
@configfile.close
|
||||||
|
|
||||||
# Build up the Gemfile for our Bundler context
|
# Build up the Gemfile for our Bundler context. We make sure to
|
||||||
|
# lock Vagrant to our current Vagrant version. In addition to that,
|
||||||
|
# we add all our plugin dependencies.
|
||||||
@gemfile = Tempfile.new("vagrant-gemfile")
|
@gemfile = Tempfile.new("vagrant-gemfile")
|
||||||
@gemfile.puts(%Q[gem "vagrant", "= #{Vagrant::VERSION}"])
|
@gemfile.puts(%Q[gem "vagrant", "= #{Vagrant::VERSION}"])
|
||||||
plugins.each do |plugin|
|
plugins.each do |plugin|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require "json"
|
require "json"
|
||||||
|
|
||||||
require_relative "paths"
|
require_relative "shared_helpers"
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
class PluginManager
|
class PluginManager
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
require "pathname"
|
require "pathname"
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
# The source root is the path to the root directory of
|
# This returns whether or not 3rd party plugins should be loaded.
|
||||||
# the Vagrant gem.
|
#
|
||||||
|
# @return [Boolean]
|
||||||
|
def self.plugins_enabled?
|
||||||
|
!ENV["VAGRANT_NO_PLUGINS"]
|
||||||
|
end
|
||||||
|
|
||||||
|
# The source root is the path to the root directory of the Vagrant source.
|
||||||
|
#
|
||||||
|
# @return [Pathname]
|
||||||
def self.source_root
|
def self.source_root
|
||||||
@source_root ||= Pathname.new(File.expand_path('../../../', __FILE__))
|
@source_root ||= Pathname.new(File.expand_path('../../../', __FILE__))
|
||||||
end
|
end
|
|
@ -139,11 +139,6 @@ en:
|
||||||
|
|
||||||
Old: %{old}
|
Old: %{old}
|
||||||
New: %{new}
|
New: %{new}
|
||||||
in_bundler: |-
|
|
||||||
You appear to be running Vagrant in a Bundler environment. Because
|
|
||||||
Vagrant should be run within installers (outside of Bundler), Vagrant
|
|
||||||
will assume that you're developing plugins and will change its behavior
|
|
||||||
in certain ways to better assist plugin development.
|
|
||||||
not_in_installer: |-
|
not_in_installer: |-
|
||||||
You appear to be running Vagrant outside of the official installers.
|
You appear to be running Vagrant outside of the official installers.
|
||||||
Note that the installers are what ensure that Vagrant has all required
|
Note that the installers are what ensure that Vagrant has all required
|
||||||
|
|
Loading…
Reference in New Issue