diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index e7107fb62..a3b13373e 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -170,6 +170,8 @@ module Vagrant # Extra env keys are the remaining opts extra_env = opts.dup + check_cwd + # Create a deterministic ID for this machine vf = nil vf = @env.vagrantfile_name[0] if @env.vagrantfile_name @@ -559,5 +561,25 @@ module Vagrant return nil if !@data_dir @data_dir.join("creator_uid") end + + def check_cwd + vagrant_cwd_filepath = @data_dir.join('vagrant_cwd') + vagrant_cwd = if File.exist?(vagrant_cwd_filepath) + File.read(vagrant_cwd_filepath).chomp + end + + if vagrant_cwd + if vagrant_cwd != @env.cwd.to_s + ui.warn(I18n.t( + 'vagrant.moved_cwd', + old_wd: vagrant_cwd, + current_wd: @env.cwd.to_s)) + + File.write(vagrant_cwd_filepath, @env.cwd) + end + else + File.write(vagrant_cwd_filepath, @env.cwd) + end + end end end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 5e36d67a4..2e6a6f5e9 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -165,6 +165,10 @@ en: description of what they do. %{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. guest_deb_installing_smb: |- Installing SMB "mount.cifs"... global_status_footer: |-