{"record":{"id":"effd2702d945e924","repo":"hasura/graphql-engine","slug":"creating-new-binary-file-w","errorCode":null,"errorMessage":"creating new binary file: %w","messagePattern":"creating new binary file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/update/update.go","lineNumber":88,"sourceCode":"\tvar op errors.Op = \"update.downloadAsset\"\n\n\tres, err := http.Get(url)\n\tif err != nil {\n\t\treturn nil, errors.E(op, errors.KindNetwork, fmt.Errorf(\"downloading asset: %w\", err))\n\t}\n\tdefer res.Body.Close()\n\n\tif res.StatusCode != http.StatusOK {\n\t\treturn nil, errors.E(op, errors.E(\"could not find the release asset\"))\n\t}\n\n\tasset, err := os.OpenFile(\n\t\tfilepath.Join(filePath, fileName),\n\t\tos.O_CREATE|os.O_WRONLY|os.O_TRUNC,\n\t\t0o755,\n\t)\n\tif err != nil {\n\t\treturn nil, errors.E(op, fmt.Errorf(\"creating new binary file: %w\", err))\n\t}\n\tdefer asset.Close()\n\n\t_, err = io.Copy(asset, res.Body)\n\tif err != nil {\n\t\treturn nil, errors.E(op, fmt.Errorf(\"saving downloaded file: %w\", err))\n\t}\n\n\treturn asset, nil\n}\n\n// HasUpdate tells us if there is a new stable or prerelease update available.\nfunc HasUpdate(\n\tcurrentVersion *semver.Version,\n\ttimeFile string,\n) (bool, *semver.Version, bool, *semver.Version, error) {\n\tvar op errors.Op = \"update.HasUpdate\"\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/update/update.go#L70-L106","documentation":"After a successful download response, downloadAsset creates the destination file with os.OpenFile(O_CREATE|O_WRONLY|O_TRUNC, 0755) to write the new binary. Any open failure (permission denied, missing parent directory, path is a directory, read-only FS) is wrapped by this error.","triggerScenarios":"Calling ApplyUpdate() when the CLI install/config directory is not writable by the current user, the target path exists as a directory, the disk is full/read-only, or a root-owned file remains from earlier sudo usage.","commonSituations":"CLI installed to /usr/local/bin without write permission, a config dir owned by root after prior sudo runs, containers with read-only filesystems, or SELinux denying writes.","solutions":["Check permissions on the install/config directory and fix ownership (chown to your user on the CLI dir); reinstall via a package manager if in a system location","Ensure the parent directory of the target path exists","Prefer user-local installs so updates never need elevated privileges"],"exampleFix":"# before\nhasura update   # fails: creating new binary file: permission denied\n\n# after\nsudo chown -R $(whoami) /usr/local/bin/hasura ~/.hasura\nhasura update","handlingStrategy":"validation","validationCode":"if _, err := os.OpenFile(filepath.Join(filePath, \".write_test\"), os.O_CREATE|os.O_WRONLY, 0o755); err != nil {\n    // pre-flight: target dir not writable, fix permissions first\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install the CLI in a user-writable location (e.g. ~/.local/bin)","Never run the CLI with sudo for routine updates","Verify write access to the install dir before triggering an update"],"tags":["filesystem","permissions","update","hasura-cli"],"backgroundTag":"file-write-permission-denied","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}