hashicorp/vagrant · warning

Vagrant requires administrator access to create SMB shares a

Error message

Vagrant requires administrator access to create SMB shares and
may request access to complete setup of configured shares.

What it means

On Windows hosts, creating SMB shares for synced folders runs an elevated PowerShell script in batches of 10 shares. Before the first batch, Vagrant prints this UAC warning once, sleeps UAC_PROMPT_WAIT seconds, and executes the script with sudo: true; a non-zero exit raises SyncedFolderSMB::Errors::DefineShareFailed with the failing share path.

Source

Thrown at plugins/hosts/windows/cap/smb.rb:109

                  name: data[:smb_id]
              end
              @@logger.info("skip creation of existing share name=#{name} id=#{data[:smb_id]}")
              next
            end

            @@logger.info("creating new share name=#{name} id=#{data[:smb_id]}")

            shares << [
              "\"#{hostpath.gsub("/", "\\")}\"",
              name,
              data[:smb_id]
            ]
          end
          if !shares.empty?
            uac_notified = false
            shares.each_slice(10) do |s_shares|
              if !uac_notified
                machine.env.ui.warn("\n" + I18n.t("vagrant_sf_smb.uac.create_warning") + "\n")
                uac_notified = true
                sleep(UAC_PROMPT_WAIT)
              end
              result = Vagrant::Util::PowerShell.execute(script_path, *s_shares, sudo: true)
              if result.exit_code != 0
                share_path = result.stdout.to_s.sub("share path: ", "")
                raise SyncedFolderSMB::Errors::DefineShareFailed,
                  host: share_path,
                  stderr: result.stderr,
                  stdout: result.stdout
              end
            end
          end
        end

        # Generate a list of existing local smb shares
        #
        # @return [Hash]

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Run Vagrant from an elevated (Administrator) terminal so share creation does not need an interactive UAC dialog
  2. Pre-create the shares yourself with New-SmbShare if you must avoid elevation during up
  3. If DefineShareFailed follows, check the share path, firewall rules, and File and Printer Sharing are enabled

Example fix

# before
vagrant up   # normal terminal -> UAC consent dialog mid-run
# after
# elevated PowerShell:
vagrant up
Defensive patterns

Strategy: validation

Validate before calling

# PowerShell preflight: is this shell elevated?
([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)

Prevention

When it happens

Trigger: `vagrant up` or `vagrant reload` with type: "smb" synced folders on a Windows host where the shares list is non-empty (new or changed host paths to expose).

Common situations: First SMB up on a Windows host; adding new shared folders mid-project; non-elevated terminals triggering UAC prompts; CI agents without interactive elevation.

Related errors


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