diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f86beb7b..1ca295383 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ IMPROVEMENTS: BUG FIXES: + - core: Global control works from directories that don't have a + Vagrantfile. - commands/package: `--base` works without crashing for VirtualBox. - guests/redhat: Fix networking issues with CentOS. [GH-3649] diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index d0cd1b206..afb12f063 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -191,6 +191,9 @@ module Vagrant # # @return [Array] def active_machines + # We have no active machines if we have no data path + return [] if !@local_data_path + machine_folder = @local_data_path.join("machines") # If the machine folder is not a directory then we just return diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index 7fc0bcc3f..be83d8977 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -602,6 +602,13 @@ VF end describe "active machines" do + it "should be empty if there is no root path" do + Dir.mktmpdir do |temp_dir| + instance = described_class.new(cwd: temp_dir) + expect(instance.active_machines).to be_empty + end + end + it "should be empty if the machines folder doesn't exist" do folder = instance.local_data_path.join("machines") expect(folder).not_to be_exist