{"record":{"id":"61929e220c1be966","repo":"matryer/xbar","slug":"download-update","errorCode":null,"errorMessage":"download update","messagePattern":"download update","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/update/update.go","lineNumber":75,"sourceCode":"\t\treturn nil, err\n\t}\n\thasUpdate := hasUpdate(u.CurrentVersion, latest.TagName)\n\tif !hasUpdate {\n\t\treturn nil, nil\n\t}\n\tvar selectedAsset *Asset\n\tfor _, asset := range latest.Assets {\n\t\tif u.SelectAsset(*latest, asset) {\n\t\t\tselectedAsset = &asset\n\t\t\tbreak\n\t\t}\n\t}\n\tif selectedAsset == nil {\n\t\treturn nil, errors.New(\"no asset selected, use SelectAssetFunc to select an asset\")\n\t}\n\terr = u.downloadAndReplaceApp(*selectedAsset)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"download update\")\n\t}\n\treturn latest, nil\n}\n\n// Restart spawns the current executable again, and terminates\n// the running one.\nfunc (u *Updater) Restart() error {\n\ttime.Sleep(1 * time.Second)\n\tthisExecuable, err := os.Executable()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"get executable\")\n\t}\n\tlog.Println(\"restarting\", thisExecuable)\n\tcmd := exec.Command(thisExecuable)\n\tcmd.SysProcAttr = &syscall.SysProcAttr{\n\t\tSetpgid: false,\n\t}\n\tcmd.Dir = filepath.Dir(thisExecuable)","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/pkg/update/update.go#L57-L93","documentation":"This error is wrapped by Updater.Update (pkg/update/update.go:75) when downloadAndReplaceApp fails to download the selected release asset and swap it in for the running application. The update flow (fetch latest release, select asset, download-and-replace) reached the download step but the download, checksum/verify, or file-replacement failed. The wrap marks the failure as occurring during the self-update download phase.","triggerScenarios":"Update() runs after SelectAssetFunc picks an asset, then u.downloadAndReplaceApp(*selectedAsset) errors: asset URL unreachable (network down, 404 after a release was deleted), download interrupted, temp-file write/permission failure, or failure replacing the running executable (file locked on Windows / text-file-busy).","commonSituations":"GitHub release asset removed or renamed so the stored URL 404s; corporate proxy/firewall blocking the download host; running from a directory the user cannot write to; antivirus locking the binary during replacement; running binary mounted read-only; TLS/proxy MITM cert issues in containers.","solutions":["Check the wrapped cause for HTTP status — 404 means the asset URL is gone; re-cut or re-upload the release asset","Verify network/proxy reachability of the asset URL from the host (curl the URL)","Ensure the executable's directory is writable by the process user (and on Windows that no process/AV holds a lock)","Run the app from a writable location rather than a read-only mount or system directory","Retry the update later; transient network failures are common","Fall back to manual download-and-replace of the binary"],"exampleFix":"// before\nlatest, err := updater.Update()\nif err != nil {\n\tlog.Fatal(err)\n}\n// after\nlatest, err := updater.Update()\nif err != nil {\n\tif strings.Contains(fmt.Sprintf(\"%+v\", err), \"404\") {\n\t\tlog.Println(\"asset missing upstream; skipping auto-update\")\n\t\treturn\n\t}\n\tlog.Printf(\"update failed, retrying in 1h: %v\", err)\n\ttime.Sleep(time.Hour)\n\tlatest, err = updater.Update()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}","handlingStrategy":"try-catch","validationCode":"resp, err := http.Head(assetURL)\nif err != nil || resp.StatusCode != http.StatusOK {\n\treturn fmt.Errorf(\"update asset unavailable: status=%v err=%v\", resp.StatusCode, err)\n}\nif dir := filepath.Dir(os.Args[0]); !writable(dir) {\n\treturn fmt.Errorf(\"install dir %s not writable\", dir)\n}","typeGuard":null,"tryCatchPattern":"latest, err := updater.Update()\nif err != nil {\n\tif strings.Contains(fmt.Sprintf(\"%+v\", err), \"download update\") {\n\t\tlog.Printf(\"auto-update failed, will retry next cycle: %v\", err)\n\t\treturn nil // degrade gracefully; app keeps running current version\n\t}\n\treturn err\n}","preventionTips":["Verify release assets exist and URLs resolve before tagging a release","Never delete old release assets that deployed clients may still reference","Run the app from a writable directory and confirm the user can replace the binary","On Windows, ensure antivirus/locks won't hold the binary during replacement","Treat update failure as non-fatal and retry on a schedule"],"tags":["go","network","self-update","download"],"backgroundTag":"download-failed","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}