hashicorp/vagrant · error · Vagrant::Errors::RSyncPostCommandError

There was an error while attempting to run the post rsync co

Error message

There was an error while attempting to run the post rsync
command for a synced folder. Please inspect the error message
below for more info.

Host path: %{hostpath}
Guest path: %{guestpath}
Error: %{message}

What it means

After a successful rsync transfer, Vagrant runs the guest's rsync_post capability (typically chown -R on the synced directory). If that capability raises any VagrantError, the helper re-raises it as RSyncPostCommandError embedding the host/guest paths and the original error's message. The data transfer succeeded; the guest-side post step failed.

Source

Thrown at plugins/synced_folders/rsync/helper.rb:236

          }
        else
          r = Vagrant::Util::Subprocess.execute(*(command + [command_opts]))
        end

        if r.exit_code != 0
          raise Vagrant::Errors::RSyncError,
            command: command.map(&:inspect).join(" "),
            guestpath: guestpath,
            hostpath: hostpath,
            stderr: r.stderr
        end

        # If we have tasks to do after rsyncing, do those.
        if machine.guest.capability?(:rsync_post)
          begin
            machine.guest.capability(:rsync_post, opts)
          rescue Vagrant::Errors::VagrantError => err
            raise Vagrant::Errors::RSyncPostCommandError,
              guestpath: guestpath,
              hostpath: hostpath,
              message: err.to_s
          end
        end
      ensure
        FileUtils.remove_entry_secure(controlpath, true) if controlpath
      end

      # Check if rsync versions support using chown option
      #
      # @param [Vagrant::Machine] machine The remote machine
      # @return [Boolean]
      def self.rsync_chown_support?(machine)
        if !RSYNC_CHOWN_REQUIREMENT.satisfied_by?(Gem::Version.new(local_rsync_version))
          return false
        end
        mrv = machine_rsync_version(machine)

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Follow the embedded message — it names the actual failing guest command (usually chown)
  2. Ensure the uid/gid in mount_options (or the default vagrant user) exists inside the guest
  3. Free disk space or relax SELinux/AppArmor in the guest if chown is denied
  4. Override the rsync_post guest capability if you must customize post-transfer behavior

Example fix

# before
config.vm.synced_folder "src", "/app", type: "rsync",
  mount_options: ["uid=9999", "gid=9999"]   # ids absent in guest -> chown fails

# after
config.vm.synced_folder "src", "/app", type: "rsync",
  mount_options: ["uid=vagrant", "gid=vagrant"]
Defensive patterns

Strategy: try-catch

Validate before calling

# confirm the mapped identities exist before enabling rsync
machine.communicate.test("id -u vagrant >/dev/null 2>&1") or raise "guest lacks 'vagrant' user for rsync_post"

Try / catch

begin
  machine.env.action_runner.run(rsync_action, env)
rescue Vagrant::Errors::RSyncPostCommandError => e
  # e.extra_data[:message] holds the original guest-side error (usually chown)
  ui.error("post-rsync step failed: #{e.extra_data[:message]}")
end

Prevention

When it happens

Trigger: rsync_post executing chown/chmod in the guest failing: mapped uid/gid not existing in the guest, read-only mount, full disk, SELinux/AppArmor denying ownership changes on the synced directory.

Common situations: Custom mount_options with wrong uid/gid; hardened guests with SELinux enforcing; guests with full disks; user 'vagrant' removed from the image.

Related errors


AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21). Data as JSON: /api/errors/ac51ad80e39fe67a. Report an issue: GitHub.