From 2575ed9dc25da6008b90dc501ebea48ef34579c1 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Mon, 26 Jun 2017 20:00:43 -0700 Subject: [PATCH 1/2] Explicitly set encodings to prevent incompatible string comparisons --- lib/vagrant/machine.rb | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index 7c2310acb..e375d08ce 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -571,19 +571,24 @@ module Vagrant # from its previous location on disk. If the machine # has moved, it prints a warning to the user. def check_cwd + desired_encoding = @env.root_path.to_s.encoding vagrant_cwd_filepath = @data_dir.join('vagrant_cwd') vagrant_cwd = if File.exist?(vagrant_cwd_filepath) - File.read(vagrant_cwd_filepath).chomp - end + File.read(vagrant_cwd_filepath, + external_encoding: desired_encoding + ).chomp + end - if vagrant_cwd.nil? - File.write(vagrant_cwd_filepath, @env.root_path) - elsif vagrant_cwd != @env.root_path.to_s - ui.warn(I18n.t( - 'vagrant.moved_cwd', - old_wd: vagrant_cwd, - current_wd: @env.root_path.to_s)) - File.write(vagrant_cwd_filepath, @env.root_path) + if vagrant_cwd != @env.root_path.to_s + if vagrant_cwd + ui.warn(I18n.t( + 'vagrant.moved_cwd', + old_wd: "#{vagrant_cwd}", + current_wd: "#{@env.root_path.to_s}")) + end + File.write(vagrant_cwd_filepath, @env.root_path.to_s, + external_encoding: desired_encoding + ) end end end From eb9ed1b39e155bba07b71496e82ff696045ef60e Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Mon, 26 Jun 2017 20:01:10 -0700 Subject: [PATCH 2/2] Update wording as machine rename is not always required --- templates/locales/en.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index af3fad1a4..a67f948a3 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -167,8 +167,8 @@ en: %{list} moved_cwd: |- This machine used to live in %{old_wd} but it's now at %{current_wd}. - Please change the name of the machine if you want to run it as a different - machine. + Depending on your current provider you may need to change the name of + the machine to run it as a different machine. guest_deb_installing_smb: |- Installing SMB "mount.cifs"... global_status_footer: |-