Allow disable of user plugins if repair command is requested
This commit is contained in:
parent
1fb4553d14
commit
d5c5561302
74
bin/vagrant
74
bin/vagrant
|
@ -20,25 +20,17 @@ if argv.include?("-v") || argv.include?("--version")
|
||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# This is kind of hacky, and I'd love to find a better way to do this, but
|
# Disable plugin loading for commands where plugins are not required
|
||||||
# if we're accessing the plugin interface, we want to NOT load plugins
|
|
||||||
# for this run, because they can actually interfere with the function
|
|
||||||
# of the plugin interface.
|
|
||||||
argv.each_index do |i|
|
argv.each_index do |i|
|
||||||
arg = argv[i]
|
arg = argv[i]
|
||||||
|
|
||||||
if !arg.start_with?("-")
|
if !arg.start_with?("-")
|
||||||
if arg == "plugin"
|
if ["plugin", "help"].include?(arg) || (arg == "box" && argv[i+1] == "list")
|
||||||
ENV["VAGRANT_NO_PLUGINS"] = "1"
|
ENV['VAGRANT_NO_PLUGINS'] = "1"
|
||||||
ENV["VAGRANT_VAGRANTFILE"] = "plugin_command_#{Time.now.to_i}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if arg == "help"
|
if arg == "plugin" && argv[i+1] == "repair"
|
||||||
ENV["VAGRANT_VAGRANTFILE"] = "plugin_command_#{Time.now.to_i}"
|
ENV['VAGRANT_DISABLE_PLUGIN_INIT'] = "1"
|
||||||
end
|
|
||||||
|
|
||||||
if arg == "box" && argv[i+1] == "list"
|
|
||||||
ENV["VAGRANT_VAGRANTFILE"] = "plugin_command_#{Time.now.to_i}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
break
|
break
|
||||||
|
@ -57,7 +49,7 @@ end
|
||||||
begin
|
begin
|
||||||
require "bundler"
|
require "bundler"
|
||||||
rescue Errno::EINVAL
|
rescue Errno::EINVAL
|
||||||
# Bundler can generated the EINVAL error during initial require, which means
|
# Bundler can generate the EINVAL error during initial require, which means
|
||||||
# nothing has yet been setup (so no access to I18n). Note that vagrant has
|
# nothing has yet been setup (so no access to I18n). Note that vagrant has
|
||||||
# failed early and copy information related to problem and possible solution.
|
# failed early and copy information related to problem and possible solution.
|
||||||
$stderr.puts "Vagrant failed to initialize at a very early stage:\n\n"
|
$stderr.puts "Vagrant failed to initialize at a very early stage:\n\n"
|
||||||
|
@ -70,32 +62,34 @@ rescue Errno::EINVAL
|
||||||
exit 255
|
exit 255
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
if(defined?(Bundler))
|
||||||
$vagrant_bundler_runtime = Bundler.setup(:default, :plugins)
|
begin
|
||||||
rescue Bundler::GemNotFound
|
$vagrant_bundler_runtime = Bundler.setup(:default, :plugins)
|
||||||
$stderr.puts "Bundler, the underlying system used to manage Vagrant plugins,"
|
rescue Bundler::GemNotFound
|
||||||
$stderr.puts "is reporting that a plugin or its dependency can't be found."
|
$stderr.puts "Bundler, the underlying system used to manage Vagrant plugins,"
|
||||||
$stderr.puts "This is usually caused by manual tampering with the 'plugins.json'"
|
$stderr.puts "is reporting that a plugin or its dependency can't be found."
|
||||||
$stderr.puts "file in the Vagrant home directory. To fix this error, please"
|
$stderr.puts "This is usually caused by manual tampering with the 'plugins.json'"
|
||||||
$stderr.puts "remove that file and reinstall all your plugins using `vagrant"
|
$stderr.puts "file in the Vagrant home directory. To fix this error, please"
|
||||||
$stderr.puts "plugin install`."
|
$stderr.puts "remove that file and reinstall all your plugins using `vagrant"
|
||||||
rescue Bundler::VersionConflict => e
|
$stderr.puts "plugin install`."
|
||||||
$stderr.puts "Vagrant experienced a version conflict with some installed plugins!"
|
rescue Bundler::VersionConflict => e
|
||||||
$stderr.puts "This usually happens if you recently upgraded Vagrant. As part of the"
|
$stderr.puts "Vagrant experienced a version conflict with some installed plugins!"
|
||||||
$stderr.puts "upgrade process, some existing plugins are no longer compatible with"
|
$stderr.puts "This usually happens if you recently upgraded Vagrant. As part of the"
|
||||||
$stderr.puts "this version of Vagrant. The recommended way to fix this is to remove"
|
$stderr.puts "upgrade process, some existing plugins are no longer compatible with"
|
||||||
$stderr.puts "your existing plugins and reinstall them one-by-one. To remove all"
|
$stderr.puts "this version of Vagrant. The recommended way to fix this is to remove"
|
||||||
$stderr.puts "plugins:"
|
$stderr.puts "your existing plugins and reinstall them one-by-one. To remove all"
|
||||||
$stderr.puts ""
|
$stderr.puts "plugins:"
|
||||||
$stderr.puts " rm -r ~/.vagrant.d/plugins.json ~/.vagrant.d/gems"
|
$stderr.puts ""
|
||||||
$stderr.puts ""
|
$stderr.puts " rm -r ~/.vagrant.d/plugins.json ~/.vagrant.d/gems"
|
||||||
$stderr.puts "Note if you have an alternate VAGRANT_HOME environmental variable"
|
$stderr.puts ""
|
||||||
$stderr.puts "set, the folders above will be in that directory rather than your"
|
$stderr.puts "Note if you have an alternate VAGRANT_HOME environmental variable"
|
||||||
$stderr.puts "user's home directory."
|
$stderr.puts "set, the folders above will be in that directory rather than your"
|
||||||
$stderr.puts ""
|
$stderr.puts "user's home directory."
|
||||||
$stderr.puts "The error message is shown below:\n\n"
|
$stderr.puts ""
|
||||||
$stderr.puts e.message
|
$stderr.puts "The error message is shown below:\n\n"
|
||||||
exit 1
|
$stderr.puts e.message
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Stdout/stderr should not buffer output
|
# Stdout/stderr should not buffer output
|
||||||
|
|
|
@ -256,7 +256,7 @@ end
|
||||||
# Setup the plugin manager and load any defined plugins
|
# Setup the plugin manager and load any defined plugins
|
||||||
require_relative "vagrant/plugin/manager"
|
require_relative "vagrant/plugin/manager"
|
||||||
plugins = Vagrant::Plugin::Manager.instance.installed_plugins
|
plugins = Vagrant::Plugin::Manager.instance.installed_plugins
|
||||||
Vagrant::Bundler.instance.init!(plugins)
|
Vagrant::Bundler.instance.init!(plugins) unless ENV['VAGRANT_DISABLE_PLUGIN_INIT'] == "1"
|
||||||
|
|
||||||
# A lambda that knows how to load plugins from a single directory.
|
# A lambda that knows how to load plugins from a single directory.
|
||||||
plugin_load_proc = lambda do |directory|
|
plugin_load_proc = lambda do |directory|
|
||||||
|
|
Loading…
Reference in New Issue