{"record":{"id":"a3799fb285492350","repo":"hashicorp/vagrant","slug":"pruning-an-smb-share-failed-details-about-the-fai","errorCode":null,"errorMessage":"Pruning an SMB share failed! Details about the failure are shown\nbelow. Please inspect the error message and correct any problems.\n\nShare name: %{name}\n\nStderr: %{stderr}\n\nStdout: %{stdout}","messagePattern":"Pruning an SMB share failed! Details about the failure are shown\nbelow\\. Please inspect the error message and correct any problems\\.\n\nShare name: %(.+?)\n\nStderr: %(.+?)\n\nStdout: %(.+?)","errorType":"exception","errorClass":"VagrantPlugins::SyncedFolderSMB::Errors::PruneShareFailed","httpStatus":null,"severity":"error","filePath":"plugins/hosts/windows/cap/smb.rb","lineNumber":63,"sourceCode":"              @@logger.info(\"removing smb share name=#{share_name} id=#{m_id}\")\n              share_name\n            else\n              @@logger.info(\"skipping smb share removal, not owned name=#{share_name}\")\n              @@logger.debug(\"smb share ID not present name=#{share_name} id=#{m_id} description=#{share_info[\"Description\"]}\")\n              nil\n            end\n          end.compact\n\n          @@logger.debug(\"shares to be removed: #{prune_shares}\")\n\n          if prune_shares.size > 0\n            machine.env.ui.warn(\"\\n\" + I18n.t(\"vagrant_sf_smb.uac.prune_warning\") + \"\\n\")\n            sleep UAC_PROMPT_WAIT\n            @@logger.info(\"remove shares: #{prune_shares}\")\n            result = Vagrant::Util::PowerShell.execute(script_path, *prune_shares, sudo: true)\n            if result.exit_code != 0\n              failed_name = result.stdout.to_s.sub(\"share name: \", \"\")\n              raise SyncedFolderSMB::Errors::PruneShareFailed,\n                name: failed_name,\n                stderr: result.stderr,\n                stdout: result.stdout\n            end\n          end\n        end\n\n        def self.smb_prepare(env, machine, folders, opts)\n          script_path = File.expand_path(\"../../scripts/set_share.ps1\", __FILE__)\n\n          shares = []\n          current_shares = existing_shares\n          folders.each do |id, data|\n            hostpath = data[:hostpath].to_s\n\n            chksum_id = Digest::MD5.hexdigest(id)\n            name = \"vgt-#{machine_id(machine)}-#{chksum_id}\"\n            data[:smb_id] ||= name","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/hosts/windows/cap/smb.rb#L45-L81","documentation":"SyncedFolderSMB::Errors::PruneShareFailed raised at plugins/hosts/windows/cap/smb.rb:63. When machines go away, Vagrant computes stale `vgt-*` shares, warns about a UAC prompt (sleeping UAC_PROMPT_WAIT), then runs the removal script elevated via `Vagrant::Util::PowerShell.execute(script_path, *prune_shares, sudo: true)`; a non-zero exit raises, with the failing share name extracted from stdout by stripping the literal \"share name: \" prefix.","triggerScenarios":"`vagrant destroy`/`halt` (or a subsequent up that prunes) on Windows where the elevated Remove-SmbShare fails: UAC prompt dismissed, a share held open by file handles, the share already deleted by someone else, or the Server (lanmanserver) service stopped.","commonSituations":"User dismisses the UAC dialog during the wait; Explorer or a process holds files in the shared path; stale vgt- shares from crashed runs; group policy restricting share management.","solutions":["Remove the named share manually in elevated PowerShell: `Remove-SmbShare -Name \"<Share name from error>\" -Force` (or `net share <name> /delete`)","Close programs holding files under the share, then retry the vagrant command","Accept the UAC elevation prompt when the prune warning appears — Vagrant waits for it","Bulk-clean stale shares when nothing is running: `Get-SmbShare vgt-* | Remove-SmbShare -Force`"],"exampleFix":"# before — share held open, prune fails during `vagrant destroy`\n# error: PruneShareFailed name=vgt-abc123-...\n# after — free the handle and remove manually, then retry\nGet-Process | Where-Object { $_.Path -like 'C:\\shared\\*' } | Stop-Object -ErrorAction SilentlyContinue\nRemove-SmbShare -Name \"vgt-abc123-...\" -Force\n# then: vagrant destroy","handlingStrategy":"fallback","validationCode":"# Before destroy, see which stale shares exist and pre-remove them\n# powershell: Get-SmbShare -Name \"vgt-*\" | Select Name,Path\nstale = `powershell -NoProfile -Command \"Get-SmbShare -Name 'vgt-*' | Select-Object -ExpandProperty Name\"`.split\nstale.each { |n| system(\"powershell -Command \\\"Remove-SmbShare -Name #{n} -Force\\\"\") }","typeGuard":null,"tryCatchPattern":"begin\n  machine.action_destroy\nrescue VagrantPlugins::SyncedFolderSMB::Errors::PruneShareFailed => e\n  warn \"prune failed for #{e.data[:name]}: #{e.data[:stderr]}\"\n  # non-fatal for the destroy workflow: log, remove manually, continue\n  system(\"powershell -Command \\\"Remove-SmbShare -Name '#{e.data[:name]}' -Force\\\"\")\nend","preventionTips":["Accept the UAC prompt when the prune warning appears","Periodically clean `Get-SmbShare vgt-*` when no machines run","Close open handles under shared paths before destroying"],"tags":["smb","windows","prune","uac","share-removal"],"backgroundTag":"smb-share-removal-failed","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}