{"record":{"id":"324e2b4f2061d2a8","repo":"hashicorp/nomad","slug":"cannot-write-nomad-binary-for-install-s","errorCode":null,"errorMessage":"cannot write nomad binary for install - %s","messagePattern":"cannot write nomad binary for install - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/windows_service_install.go","lineNumber":350,"sourceCode":"\t}\n\n\t// Create a new copy of the current binary to install\n\texeFile, err := os.Open(exePath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot open current nomad path for install - %s\", err)\n\t}\n\tdefer exeFile.Close()\n\n\t// Copy into a temporary file which can then be moved\n\t// into the correct location.\n\tdstFile, err := os.CreateTemp(os.TempDir(), \"nomad*\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot create copy - %s\", err)\n\t}\n\tdefer dstFile.Close()\n\n\tif _, err = io.Copy(dstFile, exeFile); err != nil {\n\t\treturn fmt.Errorf(\"cannot write nomad binary for install - %s\", err)\n\t}\n\tdstFile.Close()\n\n\t// With a copy ready to be moved into place, ensure that\n\t// the path is clear then move the file.\n\tif err = os.RemoveAll(opts.binaryPath); err != nil {\n\t\treturn fmt.Errorf(\"cannot remove existing nomad binary install - %s\", err)\n\t}\n\n\tif err = os.Rename(dstFile.Name(), opts.binaryPath); err != nil {\n\t\treturn fmt.Errorf(\"cannot install new nomad binary - %s\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":332,"sourceCodeEnd":366,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/windows_service_install.go#L332-L366","documentation":"binaryInstall wraps the error from io.Copy, which streams the nomad executable into the temporary file. The source binary could not be fully read or written, so the install aborts before the file is moved into place. The wrapped error identifies whether read or write failed.","triggerScenarios":"io.Copy(dstFile, exeFile) fails because the source nomad.exe is locked, unreadable, the exeFile was closed early, or the destination temp file hits a full disk / I/O error during binaryInstall.","commonSituations":"Another process (running nomad service, antivirus scan) holds the source binary open; disk fills mid-copy; corrupted or truncated source binary.","solutions":["Read the wrapped I/O error to see if the read or write side failed","Free disk space on the temp drive","Ensure no process has the source nomad binary exclusively locked and retry the install","Retry after antivirus finishes scanning the binary"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := installCmd.Run(); err != nil {\n    var werr error\n    if strings.Contains(err.Error(), \"cannot write nomad binary\") {\n        // free disk space, verify source binary is not locked, retry\n        _ = werr\n    }\n}","preventionTips":["Ensure the source binary is not locked by the running service before install","Keep adequate free space on the temp volume","Retry after antivirus scans complete"],"tags":["go","windows","filesystem","io"],"backgroundTag":"file-copy-io-error","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"}