{"record":{"id":"68e9a01e272c32e9","repo":"hashicorp/nomad","slug":"binary-install-failed-w","errorCode":null,"errorMessage":"binary install failed - %w","messagePattern":"binary install failed - %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/windows_service_install.go","lineNumber":165,"sourceCode":"\t\trunning, err := nmdSvc.IsRunning()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to determine service state - %w\", err)\n\t\t}\n\t\tif running && !opts.reinstall {\n\t\t\treturn fmt.Errorf(\"service is already running. Please run the\\ncommand again with -reinstall to stop the service and install.\")\n\t\t}\n\n\t\tif running {\n\t\t\tc.Ui.Output(\"  Stopping existing nomad service\")\n\t\t\tif err := nmdSvc.Stop(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"unable to stop existing service - %w\", err)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Install the nomad binary into the system\n\tif err = c.binaryInstall(opts); err != nil {\n\t\treturn fmt.Errorf(\"binary install failed - %w\", err)\n\t}\n\n\tc.Ui.Output(fmt.Sprintf(\"  Nomad binary installed to: %s\", opts.binaryPath))\n\n\t// Create a configuration directory and add\n\t// a basic configuration file if no configuration\n\t// currently exists\n\tif err = c.configInstall(opts); err != nil {\n\t\treturn fmt.Errorf(\"configuration install failed - %w\", err)\n\t}\n\n\tc.Ui.Output(fmt.Sprintf(\"  Nomad configuration directory: %s\", opts.configDir))\n\tc.Ui.Output(fmt.Sprintf(\"  Nomad agent data directory: %s\", opts.configDir))\n\n\t// Now let's install that service\n\tif err := c.serviceInstall(m, opts); err != nil {\n\t\treturn fmt.Errorf(\"service install failed - %w\", err)\n\t}","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/windows_service_install.go#L147-L183","documentation":"Wraps the failure of `binaryInstall`, which copies the Nomad binary to the target install path during `windows install`. Any filesystem error (missing source binary, permission denied, target locked) is surfaced here with %w.","triggerScenarios":"The running executable or source binary cannot be copied to opts.binaryPath: destination file locked by the running service, insufficient privileges, or source path missing.","commonSituations":"Target binary in use because the service wasn't fully stopped; installing into a protected directory without elevation; AV software quarantining the copy.","solutions":["Ensure the Nomad service is stopped (`sc query nomad` shows STOPPED) before installing","Run the command from an elevated shell","Check write permission / free disk space on the target directory","Add an antivirus exclusion for the Nomad install path and retry"],"exampleFix":"// before\nnomad windows install\n// after\nsc.exe stop nomad; nomad windows install -reinstall","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(opts.binaryPath); err == nil {\n\tif f, e := os.OpenFile(opts.binaryPath, os.O_RDWR, 0o644); e != nil {\n\t\tlog.Fatalf(\"target binary locked or unwritable: %v\", e)\n\t} else { f.Close() }\n}","typeGuard":null,"tryCatchPattern":"if err := c.binaryInstall(opts); err != nil {\n\tif errors.Is(err, os.ErrPermission) { /* retry elevated */ }\n\treturn fmt.Errorf(\"binary install failed - %w\", err)\n}","preventionTips":["Stop the Nomad service before replacing its binary","Check disk space and directory ACLs on the install path","Run from an elevated shell","Exclude the install path from antivirus scanning"],"tags":["windows","filesystem","installation"],"backgroundTag":"file-copy-permission-denied","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}