hashicorp/vagrant · error · VagrantPlugins::SyncedFolderSMB::Errors::DefineShareFailed
Exporting an SMB share failed! Details about the failure are
Error message
Exporting an SMB share failed! Details about the failure are shown
below. Please inspect the error message and correct any problems.
Host path: %{host}
Stderr: %{stderr}
Stdout: %{stdout} What it means
SyncedFolderSMB::Errors::DefineShareFailed raised at plugins/hosts/windows/cap/smb.rb:116 in smb_prepare. Shares are created in batches of 10 by invoking the elevated set_share.ps1 (`Vagrant::Util::PowerShell.execute(script_path, *s_shares, sudo: true)`) after a UAC warning; a non-zero exit raises with the failing host path extracted from stdout ("share path: " prefix stripped) plus stderr/stdout.
Source
Thrown at plugins/hosts/windows/cap/smb.rb:116
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]
def self.existing_shares
shares = get_smbshares || get_netshares
if shares.nil?
raise SyncedFolderSMB::Errors::SMBListFailed
end
@@logger.debug("local share listing: #{shares}")
sharesView on GitHub (pinned to 35f3160f4a)
Solutions
- Read Stderr — the underlying New-SmbShare/`net share` failure is printed there
- Ensure the host path exists locally and your account may share it
- Accept the UAC prompt, or run vagrant from an already-elevated shell
- Start the Server service (`net start lanmanserver`) and `vagrant reload`
Defensive patterns
Strategy: validation
Validate before calling
# Every SMB host path must exist locally before vagrant creates shares
["C:/path/to/share"].each do |p|
abort "SMB host path missing: #{p}" unless File.directory?(p)
end
# and the Server service must run:
system("net start lanmanserver >/dev/null 2>&1") || abort "Start the Server service" Try / catch
begin
env.machine_action(:up)
rescue VagrantPlugins::SyncedFolderSMB::Errors::DefineShareFailed => e
puts "share creation failed for #{e.data[:host]}:\n#{e.data[:stderr]}"
# verify path/elevation, start lanmanserver, then retry
raise
end Prevention
- Accept the UAC prompt (or run vagrant elevated) when the share-creation warning appears
- Ensure host paths are local, existing directories on mounted drives
- Keep the Server (lanmanserver) service enabled
When it happens
Trigger: `vagrant up`/`reload` with SMB folders on Windows where share creation fails: UAC elevation declined during the wait, host path invalid or inaccessible, Windows share-count/ACL limits hit, or the LanmanServer service stopped.
Common situations: UAC prompt dismissed or timing out; host_path on a nonexistent drive or a not-yet-mounted network path; group policy/AV blocking share creation; Server service disabled on tuned machines.
Related errors
- Pruning an SMB share failed! Details about the failure are s
- Vagrant is unable to setup a requested SMB share. An SMB sha
- Vagrant attempted to execute the capability '%{cap}' on the
- Vagrant requires administrator access to create SMB shares a
- The synced folder type '%{type}' is reporting as unusable fo
AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21).
Data as JSON: /api/errors/98666d62940077b1.
Report an issue: GitHub.