From e4399a57246824bbdb4aaf99d7dd0d216aed7e4c Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 10 Apr 2018 08:05:23 -0700 Subject: [PATCH] Check Windows installed Vagrant version using --version Using the --version flag keeps Vagrant from doing a full startup and prevents the Vagrantfile from being parsed. This makes the version check faster, and stops things like syntax errors within a Vagrantfile from causing an unexpected error. Fixes #9635 --- lib/vagrant/util/platform.rb | 4 ++-- test/unit/vagrant/util/platform_test.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb index bcf66c751..5bc0a603b 100644 --- a/lib/vagrant/util/platform.rb +++ b/lib/vagrant/util/platform.rb @@ -561,9 +561,9 @@ module Vagrant def wsl_validate_matching_vagrant_versions! valid = false if Util::Which.which("vagrant.exe") - result = Util::Subprocess.execute("vagrant.exe", "version") + result = Util::Subprocess.execute("vagrant.exe", "--version") if result.exit_code == 0 - windows_version = result.stdout.match(/Installed Version: (?[\w.-]+)/) + windows_version = result.stdout.match(/Vagrant (?[\w.-]+)/) if windows_version windows_version = windows_version[:version].strip valid = windows_version == Vagrant::VERSION diff --git a/test/unit/vagrant/util/platform_test.rb b/test/unit/vagrant/util/platform_test.rb index 80100e349..f43afd1d8 100644 --- a/test/unit/vagrant/util/platform_test.rb +++ b/test/unit/vagrant/util/platform_test.rb @@ -185,8 +185,8 @@ describe Vagrant::Util::Platform do before do allow(Vagrant::Util::Which).to receive(:which).and_return(true) - allow(Vagrant::Util::Subprocess).to receive(:execute).with("vagrant.exe", "version"). - and_return(double(exit_code: 0, stdout: "Installed Version: #{exe_version}")) + allow(Vagrant::Util::Subprocess).to receive(:execute).with("vagrant.exe", "--version"). + and_return(double(exit_code: 0, stdout: "Vagrant #{exe_version}")) end it "should not raise an error" do