From e547b263099bd2d7f55cd1fe1ee85d96b7bd70d0 Mon Sep 17 00:00:00 2001 From: slackfan Date: Fri, 7 Sep 2018 09:27:01 +0200 Subject: [PATCH 1/3] Don't compare paths by String The implemented String comparison is misleading on Windows as it does not consider that paths on Windows are case insensitive Signed-off-by: Alexander Fischer --- lib/vagrant/machine.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index 88ef368bd..f7f190d63 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -4,6 +4,7 @@ require "digest/md5" require "thread" require "log4r" +require "vagrant/util/platform" module Vagrant # This represents a machine that Vagrant manages. This provides a singular @@ -593,7 +594,7 @@ module Vagrant ).chomp end - if vagrant_cwd != @env.root_path.to_s + if !File.identical?(vagrant_cwd.to_s, @env.root_path.to_s) if vagrant_cwd ui.warn(I18n.t( 'vagrant.moved_cwd', From 59ecf95b0d1586f7edbc644fd34e6821c54ef3ab Mon Sep 17 00:00:00 2001 From: slackfan Date: Fri, 7 Sep 2018 09:34:42 +0200 Subject: [PATCH 2/3] Remove unnessary import Signed-off-by: Alexander Fischer --- lib/vagrant/machine.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index f7f190d63..450e21fc1 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -4,7 +4,6 @@ require "digest/md5" require "thread" require "log4r" -require "vagrant/util/platform" module Vagrant # This represents a machine that Vagrant manages. This provides a singular From dac78eb6260a5160feab2514258752903dd41b3a Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 18 Sep 2018 13:58:07 -0700 Subject: [PATCH 3/3] Add test for identical file paths --- test/unit/vagrant/machine_test.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/unit/vagrant/machine_test.rb b/test/unit/vagrant/machine_test.rb index 639d14b8d..02646e353 100644 --- a/test/unit/vagrant/machine_test.rb +++ b/test/unit/vagrant/machine_test.rb @@ -370,6 +370,26 @@ describe Vagrant::Machine do end end + it 'should not warn if dirs are same but different cases' do + action_name = :destroy + callable = lambda { |_env| } + original_cwd = env.cwd.to_s + + allow(provider).to receive(:action).with(action_name).and_return(callable) + allow(subject.ui).to receive(:warn) + + instance.action(action_name) + + expect(subject.ui).to_not have_received(:warn) + + # In cygwin or other windows shell, it might have a path like + # c:/path and C:/path + # which are the same. + allow(env).to receive(:root_path).and_return(original_cwd.upcase) + expect(subject.ui).to_not have_received(:warn) + instance.action(action_name) + end + context "if in a subdir" do let (:data_dir) { env.cwd }