diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 5130ef177..1a4e06969 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -668,6 +668,10 @@ module Vagrant error_key(:push_strategy_not_provided) end + class RsyncChownCommandError < VagrantError + error_key(:rsync_chown_command_error) + end + class RSyncError < VagrantError error_key(:rsync_error) end diff --git a/plugins/synced_folders/rsync/command/rsync_auto.rb b/plugins/synced_folders/rsync/command/rsync_auto.rb index b74abf432..9706666de 100644 --- a/plugins/synced_folders/rsync/command/rsync_auto.rb +++ b/plugins/synced_folders/rsync/command/rsync_auto.rb @@ -217,6 +217,10 @@ module VagrantPlugins # halt is happening. Just notify the user but don't fail out. opts[:machine].ui.error(I18n.t( "vagrant.rsync_communicator_not_ready_callback")) + rescue Vagrant::Errors::RsyncChownCommandError + # Error executing rsync chown command + opts[:machine].ui.error(I18n.t( + "vagrant.rsync_chown_command_error")) rescue Vagrant::Errors::RSyncError => e # Error executing rsync, so show an error opts[:machine].ui.error(I18n.t( diff --git a/plugins/synced_folders/rsync/default_unix_cap.rb b/plugins/synced_folders/rsync/default_unix_cap.rb index 1f4d286f7..3bf88049a 100644 --- a/plugins/synced_folders/rsync/default_unix_cap.rb +++ b/plugins/synced_folders/rsync/default_unix_cap.rb @@ -23,7 +23,13 @@ module VagrantPlugins if opts.key?(:chown) && !opts[:chown] return end - machine.communicate.sudo(build_rsync_chown(opts)) + + error_opts = { + error_class: Vagrant::Errors::RsyncChownCommandError, + error_key: :rsync_chown_command_error + } + + machine.communicate.sudo(build_rsync_chown(opts), error_opts) end def build_rsync_chown(opts) @@ -38,7 +44,7 @@ module VagrantPlugins "find #{guest_path} #{exclusions}" \ "'!' -type l -a " \ "'(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -exec " \ - "chown #{opts[:owner]}:#{opts[:group]} '{}' + || :" + "chown #{opts[:owner]}:#{opts[:group]} '{}' +" end end end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 5af7bdb11..4c5c12409 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -235,6 +235,10 @@ en: repeats, then please fix the issue: %{message} + rsync_chown_command_error: |- + There was an error while executing find and chown command, when file missing. + This may not be critical since rsync chown command sometimes fails, but if this message + repeats, then please fix the issue. rsync_communicator_not_ready: |- The machine is reporting that it is not ready for rsync to communicate with it. Verify that this machine is properly running.