core: request users upgrade plugins if they're old
This commit is contained in:
parent
236141ba90
commit
d354cdda4a
|
@ -740,21 +740,34 @@ module Vagrant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This keeps track of the old plugins that need to be reinstalled
|
||||||
|
# because they were installed with an old version of Ruby.
|
||||||
|
reinstall = []
|
||||||
|
|
||||||
# Load the plugins
|
# Load the plugins
|
||||||
plugins_json_file = @home_path.join("plugins.json")
|
plugins_json_file = @home_path.join("plugins.json")
|
||||||
@logger.debug("Loading plugins from: #{plugins_json_file}")
|
@logger.debug("Loading plugins from: #{plugins_json_file}")
|
||||||
if plugins_json_file.file?
|
state = VagrantPlugins::CommandPlugin::StateFile.new(plugins_json_file)
|
||||||
data = JSON.parse(plugins_json_file.read)
|
state.installed_plugins.each do |name, extra|
|
||||||
data["installed"].each do |plugin|
|
# If the Ruby version changed, then they need to reinstall the plugin
|
||||||
@logger.info("Loading plugin from JSON: #{plugin}")
|
if extra["ruby_version"] != RUBY_VERSION
|
||||||
begin
|
reinstall << name
|
||||||
Vagrant.require_plugin(plugin)
|
next
|
||||||
rescue Errors::PluginLoadError => e
|
|
||||||
@ui.error(e.message + "\n")
|
|
||||||
rescue Errors::PluginLoadFailed => e
|
|
||||||
@ui.error(e.message + "\n")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@logger.info("Loading plugin from JSON: #{plugin}")
|
||||||
|
begin
|
||||||
|
Vagrant.require_plugin(plugin)
|
||||||
|
rescue Errors::PluginLoadError => e
|
||||||
|
@ui.error(e.message + "\n")
|
||||||
|
rescue Errors::PluginLoadFailed => e
|
||||||
|
@ui.error(e.message + "\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if !reinstall.empty?
|
||||||
|
@ui.warn(I18n.t("vagrant.plugin_needs_reinstall",
|
||||||
|
names: reinstall.join(", ")))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ module VagrantPlugins
|
||||||
def add_plugin(name)
|
def add_plugin(name)
|
||||||
if !@data["installed"].has_key?(name)
|
if !@data["installed"].has_key?(name)
|
||||||
@data["installed"][name] = {
|
@data["installed"][name] = {
|
||||||
|
"ruby_version" => RUBY_VERSION,
|
||||||
"vagrant_version" => Vagrant::VERSION,
|
"vagrant_version" => Vagrant::VERSION,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -65,6 +66,7 @@ module VagrantPlugins
|
||||||
new_installed = {}
|
new_installed = {}
|
||||||
(@data["installed"] || []).each do |plugin|
|
(@data["installed"] || []).each do |plugin|
|
||||||
new_installed[plugin] = {
|
new_installed[plugin] = {
|
||||||
|
"ruby_version" => "0",
|
||||||
"vagrant_version" => "0",
|
"vagrant_version" => "0",
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,7 +42,6 @@ en:
|
||||||
to automatically delete Chef nodes and clients.
|
to automatically delete Chef nodes and clients.
|
||||||
chef_run_list_empty: |-
|
chef_run_list_empty: |-
|
||||||
Warning: Chef run list is empty. This may not be what you want.
|
Warning: Chef run list is empty. This may not be what you want.
|
||||||
|
|
||||||
docker_installing: |-
|
docker_installing: |-
|
||||||
Installing Docker (%{version}) onto machine...
|
Installing Docker (%{version}) onto machine...
|
||||||
docker_pulling_images:
|
docker_pulling_images:
|
||||||
|
@ -56,7 +55,23 @@ en:
|
||||||
docker_auto_start_not_available: |-
|
docker_auto_start_not_available: |-
|
||||||
Unable to configure automatic restart of Docker containers on
|
Unable to configure automatic restart of Docker containers on
|
||||||
the guest machine
|
the guest machine
|
||||||
|
plugin_needs_reinstall: |-
|
||||||
|
The following plugins were installed with a version of Vagrant
|
||||||
|
that had different versions of underlying components. Because
|
||||||
|
these component versions were changed (which rarely happens),
|
||||||
|
the plugins must be uninstalled and reinstalled.
|
||||||
|
|
||||||
|
To ensure that all the dependencies are properly updated as well
|
||||||
|
it is _highly recommended_ to do a `vagrant plugin uninstall`
|
||||||
|
prior to reinstalling.
|
||||||
|
|
||||||
|
This message will not go away until all the plugins below are
|
||||||
|
either uninstalled or uninstalled then reinstalled.
|
||||||
|
|
||||||
|
The plugins below will not be loaded until they're uninstalled
|
||||||
|
and reinstalled:
|
||||||
|
|
||||||
|
%{names}
|
||||||
provisioner_cleanup: |-
|
provisioner_cleanup: |-
|
||||||
Running cleanup tasks for '%{name}' provisioner...
|
Running cleanup tasks for '%{name}' provisioner...
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,10 @@ describe VagrantPlugins::CommandPlugin::StateFile do
|
||||||
instance = described_class.new(path)
|
instance = described_class.new(path)
|
||||||
plugins = instance.installed_plugins
|
plugins = instance.installed_plugins
|
||||||
expect(plugins.length).to eql(1)
|
expect(plugins.length).to eql(1)
|
||||||
expect(plugins["foo"]).to eql({ "vagrant_version" => Vagrant::VERSION })
|
expect(plugins["foo"]).to eql({
|
||||||
|
"ruby_version" => RUBY_VERSION,
|
||||||
|
"vagrant_version" => Vagrant::VERSION,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should remove plugins" do
|
it "should remove plugins" do
|
||||||
|
@ -63,6 +66,7 @@ describe VagrantPlugins::CommandPlugin::StateFile do
|
||||||
it "should have the right installed plugins" do
|
it "should have the right installed plugins" do
|
||||||
plugins = subject.installed_plugins
|
plugins = subject.installed_plugins
|
||||||
expect(plugins.keys).to eql(["foo"])
|
expect(plugins.keys).to eql(["foo"])
|
||||||
|
expect(plugins["foo"]["ruby_version"]).to eql("0")
|
||||||
expect(plugins["foo"]["vagrant_version"]).to eql("0")
|
expect(plugins["foo"]["vagrant_version"]).to eql("0")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue