{"record":{"id":"ecab595b1e27c993","repo":"hashicorp/vagrant","slug":"vagrant-failed-to-automatically-start-the-smb-serv","errorCode":null,"errorMessage":"Vagrant failed to automatically start the SMB service. Ensure the\nrequired services can be started and try again.\n\nCommand: %{command}\n\nStderr: %{stderr}\n\nStdout: %{stdout}","messagePattern":"Vagrant failed to automatically start the SMB service\\. Ensure the\nrequired services can be started and try again\\.\n\nCommand: %(.+?)\n\nStderr: %(.+?)\n\nStdout: %(.+?)","errorType":"exception","errorClass":"VagrantPlugins::SyncedFolderSMB::Errors::SMBStartFailed","httpStatus":null,"severity":"error","filePath":"plugins/hosts/darwin/cap/smb.rb","lineNumber":30,"sourceCode":"        def self.smb_installed(env)\n          File.exist?(\"/usr/sbin/sharing\")\n        end\n\n        # Check if the required SMB services are loaded and enabled. If they are\n        # not, then start them up\n        def self.smb_start(env)\n          result = Vagrant::Util::Subprocess.execute(\"pwpolicy\", \"gethashtypes\")\n          if result.exit_code == 0 && !result.stdout.include?(\"SMB-NT\")\n            @@logger.error(\"SMB compatible password has not been stored\")\n            raise SyncedFolderSMB::Errors::SMBCredentialsMissing\n          end\n          result = Vagrant::Util::Subprocess.execute(\"launchctl\", \"list\", \"com.apple.smb.preferences\")\n          if result.exit_code != 0\n            @@logger.warn(\"smb preferences service not enabled. enabling and starting...\")\n            cmd = [\"/bin/launchctl\", \"load\", \"-w\", \"/System/Library/LaunchDaemons/com.apple.smb.preferences.plist\"]\n            result = Vagrant::Util::Subprocess.execute(\"/usr/bin/sudo\", *cmd)\n            if result.exit_code != 0\n              raise SyncedFolderSMB::Errors::SMBStartFailed,\n                command: cmd.join(\" \"),\n                stderr: result.stderr,\n                stdout: result.stdout\n            end\n          end\n          result = Vagrant::Util::Subprocess.execute(\"launchctl\", \"list\", \"com.apple.smbd\")\n          if result.exit_code != 0\n            @@logger.warn(\"smbd service not enabled. enabling and starting...\")\n            cmd = [\"/bin/launchctl\", \"load\", \"-w\", \"/System/Library/LaunchDaemons/com.apple.smbd.plist\"]\n            result = Vagrant::Util::Subprocess.execute(\"/usr/bin/sudo\", *cmd)\n            if result.exit_code != 0\n              raise SyncedFolderSMB::Errors::SMBStartFailed,\n                command: cmd.join(\" \"),\n                stderr: result.stderr,\n                stdout: result.stdout\n            end\n            Vagrant::Util::Subprocess.execute(\"/usr/bin/sudo\", \"/bin/launchctl\", \"start\", \"com.apple.smbd\")\n          end","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/hosts/darwin/cap/smb.rb#L12-L48","documentation":"SyncedFolderSMB::Errors::SMBStartFailed raised at plugins/hosts/darwin/cap/smb.rb:30. Before using SMB synced folders, the Darwin cap starts the SMB preference daemon: it runs `launchctl list com.apple.smb.preferences`, and when that fails it executes `sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.smb.preferences.plist`; a non-zero exit raises with the exact command and its stderr/stdout.","triggerScenarios":"A Vagrantfile with `type: \"smb\"` synced folders on macOS where the SMB preferences service cannot be enabled — sudo denied or its prompt unavailable (non-interactive shell), SIP/MDM blocking loads of system daemons, or the plist/service damaged.","commonSituations":"File Sharing never enabled in System Settings → Sharing; CI runners or IDEs without a TTY so sudo cannot prompt; corporate MDM policies restricting launchctl on system daemons; broken com.apple.smb.preferences.plist after an OS update.","solutions":["Enable File Sharing manually: System Settings → General → Sharing → File Sharing, then `vagrant reload`","Run the exact Command printed in the error (`sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.smb.preferences.plist`) in Terminal and read its output","Verify sudo works for your user in this shell (no hanging password prompt, not denied by sudoers)","If SMB stays broken, switch the synced folder to another type (nfs, virtualbox, rsync)"],"exampleFix":"# before — Vagrantfile\nconfig.vm.synced_folder \"/Users/me/data\", \"/data\", type: \"smb\"\n# after — use NFS on macOS when the SMB daemons cannot start\nconfig.vm.synced_folder \"/Users/me/data\", \"/data\", type: \"nfs\"","handlingStrategy":"validation","validationCode":"# macOS pre-flight before using SMB synced folders\nok = system(\"launchctl list com.apple.smb.preferences >/dev/null 2>&1\") ||\n     system(\"sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.smb.preferences.plist\")\nabort \"Enable macOS File Sharing (System Settings > Sharing) first\" unless ok","typeGuard":null,"tryCatchPattern":"begin\n  env.machine_action(:up)\nrescue VagrantPlugins::SyncedFolderSMB::Errors::SMBStartFailed => e\n  puts \"could not start SMB service: #{e.data[:command]}\\n#{e.data[:stderr]}\"\n  # offer switching folder type to nfs instead of retrying\n  raise\nend","preventionTips":["Enable File Sharing in System Settings before the first SMB synced-folder up","Run vagrant in an interactive shell so sudo prompts work","Prefer NFS for macOS hosts unless SMB credentials are required"],"tags":["smb","macos","launchctl","synced-folders","service-start"],"backgroundTag":"service-start-failed","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}