hashicorp/vagrant · warning
Vagrant requires administrator access for pruning SMB shares
Error message
Vagrant requires administrator access for pruning SMB shares and may request access to complete removal of stale shares.
What it means
On Windows hosts, Vagrant prunes stale SMB shares (shares whose Vagrant-managed ID no longer belongs to an active machine) by running an elevated PowerShell script. Before executing it, Vagrant prints this UAC warning, sleeps UAC_PROMPT_WAIT seconds, and then invokes the script with sudo: true, which may raise a consent dialog; a non-zero exit raises SyncedFolderSMB::Errors::PruneShareFailed.
Source
Thrown at plugins/hosts/windows/cap/smb.rb:57
def self.smb_cleanup(env, machine, opts)
script_path = File.expand_path("../../scripts/unset_share.ps1", __FILE__)
m_id = machine_id(machine)
prune_shares = existing_shares.map do |share_name, share_info|
if share_info["Description"].to_s.start_with?("vgt-#{m_id}-")
@@logger.info("removing smb share name=#{share_name} id=#{m_id}")
share_name
else
@@logger.info("skipping smb share removal, not owned name=#{share_name}")
@@logger.debug("smb share ID not present name=#{share_name} id=#{m_id} description=#{share_info["Description"]}")
nil
end
end.compact
@@logger.debug("shares to be removed: #{prune_shares}")
if prune_shares.size > 0
machine.env.ui.warn("\n" + I18n.t("vagrant_sf_smb.uac.prune_warning") + "\n")
sleep UAC_PROMPT_WAIT
@@logger.info("remove shares: #{prune_shares}")
result = Vagrant::Util::PowerShell.execute(script_path, *prune_shares, sudo: true)
if result.exit_code != 0
failed_name = result.stdout.to_s.sub("share name: ", "")
raise SyncedFolderSMB::Errors::PruneShareFailed,
name: failed_name,
stderr: result.stderr,
stdout: result.stdout
end
end
end
def self.smb_prepare(env, machine, folders, opts)
script_path = File.expand_path("../../scripts/set_share.ps1", __FILE__)
shares = []
current_shares = existing_sharesView on GitHub (pinned to 35f3160f4a)
Solutions
- Run Vagrant from an elevated (Administrator) terminal so the elevated PowerShell call needs no interactive consent
- Remove stale shares yourself in an elevated shell: `Remove-SmbShare -Name <share>` or via fsmgmt.msc
- Use `vagrant destroy` to tear down machines so share pruning has little to do
Example fix
# before vagrant up # from a normal terminal, UAC dialog may appear mid-run # after # open an elevated PowerShell, then: 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
- Run Vagrant from an Administrator terminal whenever SMB folders are involved
- Tear down machines with `vagrant destroy` instead of deleting state by hand
- Periodically audit stale shares with Get-SmbShare and remove them yourself
When it happens
Trigger: Teardown or setup on a Windows host where prune_shares is non-empty — previously created Vagrant SMB shares whose machines no longer exist, e.g. after deleting .vagrant state or removing machines by hand.
Common situations: Leftover shares from manually deleted machines; running Vagrant from a non-elevated terminal so a UAC dialog interrupts the flow; CI agents without interactive elevation.
Related errors
- Vagrant requires administrator access to create SMB shares a
- Pruning an SMB share failed! Details about the failure are s
- The synced folder type '%{type}' is reporting as unusable fo
- Exporting an SMB share failed! Details about the failure are
- vagrant.commands.box.no_installed_boxes
AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21).
Data as JSON: /api/errors/21ccdfff370b42b6.
Report an issue: GitHub.