From 7fbe8bcabc333170a778017685be35be87809eb4 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 21 Jun 2019 10:57:37 -0700 Subject: [PATCH] Fix plugin discovery loading when no data directory is available If the local data directory is unavailable, there will be no local file to use within the plugin manager. Check for local file before returning result, otherwise just return an empty hash. --- lib/vagrant/environment.rb | 6 +++++- test/unit/vagrant/environment_test.rb | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index c7941ed27..2eb35bec9 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -1021,7 +1021,11 @@ module Vagrant ui.warn(I18n.t("vagrant.plugins.local.install_rerun_command")) exit(-1) end - Vagrant::Plugin::Manager.instance.local_file.installed_plugins + if Vagrant::Plugin::Manager.instance.local_file + Vagrant::Plugin::Manager.instance.local_file.installed_plugins + else + {} + end end # This method copies the private key into the home directory if it diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index ec517aafa..834dd418d 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -1561,10 +1561,18 @@ VF allow(plugin_manager).to receive(:load_plugins) end + context "when local data directory does not exist" do + let(:local_file) { nil } + + it "should properly return empty result" do + expect(instance.send(:process_configured_plugins)).to be_empty + end + end + context "plugins are disabled" do before{ allow(Vagrant).to receive(:plugins_enabled?).and_return(false) } - it "should return nil" do + it "should return empty result" do expect(instance.send(:process_configured_plugins)).to be_nil end end