{"record":{"id":"1c1199272a1cd400","repo":"hasura/graphql-engine","slug":"download-asset-w","errorCode":null,"errorMessage":"download asset: %w","messagePattern":"download asset: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/update/update.go","lineNumber":146,"sourceCode":"// ApplyUpdate downloads and applies the update indicated by version v.\nfunc ApplyUpdate(v *semver.Version) error {\n\tvar op errors.Op = \"update.ApplyUpdate\"\n\t// get the current executable\n\texe, err := getExecutablePath()\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"find executable: %w\", err))\n\t}\n\n\t// extract the filename and path\n\texePath := filepath.Dir(exe)\n\texeName := filepath.Base(exe)\n\n\t// download the new binary\n\tasset, err := downloadAsset(\n\t\tbuildAssetURL(v.String()), \".\"+exeName+\".new\", exePath,\n\t)\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"download asset: %w\", err))\n\t}\n\n\t// get the downloaded binary name and build the absolute path\n\tnewExe := asset.Name()\n\n\t// build name and absolute path for saving old binary\n\toldExeName := \".\" + exeName + \".old\"\n\toldExe := filepath.Join(exePath, oldExeName)\n\n\t// delete any existing old binary file - this is necessary on Windows for two reasons:\n\t// 1. after a successful update, Windows can't remove the .old file because the process is still running\n\t// 2. windows rename operations fail if the destination file already exists\n\t_ = os.Remove(oldExe)\n\n\t// rename the current binary as old binary\n\terr = os.Rename(exe, oldExe)\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"rename exe to old: %w\", err))","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/update/update.go#L128-L164","documentation":"ApplyUpdate wraps downloadAsset's failure when fetching the new release binary for version v (cli/update/update.go:146). The wrapped error is typically error 490 (io.Copy failure) or an earlier failure in creating/requesting the asset URL — the download step of the self-update could not complete.","triggerScenarios":"ApplyUpdate(v) where buildAssetURL(v.String()) is wrong (no such release asset for that version/OS/arch), the network fails, or the destination '.<exeName>.new' cannot be created in the executable's directory.","commonSituations":"Version v was a prerelease or asset names don't match the expected pattern; no write permission in /usr/local/bin (installed as root, run as user); proxy blocking the release download; disk full.","solutions":["Check write permissions on the executable's directory (chmod/chown or reinstall under a user-writable path).","Verify the asset URL exists: curl -I the URL printed by buildAssetURL for your OS/arch.","Retry after fixing network issues; clean leftover .<exe>.new files first.","Confirm the version actually has published binaries for your platform."],"exampleFix":"# before\n$ cli update\n# error: download asset: creating new binary file: permission denied\n\n# after\n$ sudo chown -R $(whoami) $(dirname $(which cli))\n$ cli update","handlingStrategy":"validation","validationCode":"dir := filepath.Dir(exe)\nif info, err := os.Stat(dir); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"install dir missing: %s\", dir)\n}\nf, err := os.CreateTemp(dir, \".wtest\")\nif err != nil { return fmt.Errorf(\"install dir not writable: %w\", err) }\nf.Close(); os.Remove(f.Name())","typeGuard":null,"tryCatchPattern":"if err := update.ApplyUpdate(v); err != nil {\n    if strings.Contains(err.Error(), \"download asset\") {\n        os.Remove(filepath.Join(dir, \".\"+exeName+\".new\")) // cleanup\n    }\n    return err\n}","preventionTips":["Pre-check writability of the install directory before updating.","Verify the release exists for your OS/arch before calling ApplyUpdate.","Run updates with adequate permissions (or install under a user-owned prefix)."],"tags":["go","self-update","download","permissions"],"backgroundTag":"release-asset-download-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}