hasura/graphql-engine · error
creating new binary file: %w
Error message
creating new binary file: %w
What it means
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.
Source
Thrown at cli/update/update.go:88
var op errors.Op = "update.downloadAsset"
res, err := http.Get(url)
if err != nil {
return nil, errors.E(op, errors.KindNetwork, fmt.Errorf("downloading asset: %w", err))
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return nil, errors.E(op, errors.E("could not find the release asset"))
}
asset, err := os.OpenFile(
filepath.Join(filePath, fileName),
os.O_CREATE|os.O_WRONLY|os.O_TRUNC,
0o755,
)
if err != nil {
return nil, errors.E(op, fmt.Errorf("creating new binary file: %w", err))
}
defer asset.Close()
_, err = io.Copy(asset, res.Body)
if err != nil {
return nil, errors.E(op, fmt.Errorf("saving downloaded file: %w", err))
}
return asset, nil
}
// HasUpdate tells us if there is a new stable or prerelease update available.
func HasUpdate(
currentVersion *semver.Version,
timeFile string,
) (bool, *semver.Version, bool, *semver.Version, error) {
var op errors.Op = "update.HasUpdate"
View on GitHub (pinned to 724551b9ae)
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
Example fix
# before hasura update # fails: creating new binary file: permission denied # after sudo chown -R $(whoami) /usr/local/bin/hasura ~/.hasura hasura update
Defensive patterns
Strategy: validation
Validate before calling
if _, err := os.OpenFile(filepath.Join(filePath, ".write_test"), os.O_CREATE|os.O_WRONLY, 0o755); err != nil {
// pre-flight: target dir not writable, fix permissions first
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- creating metadata file %s failed: %w
- creating target migrations directory: %w
- creating target seeds directory: %w
- failed writing current time to file: %w
- error generating codegen for action %s: %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/effd2702d945e924.
Report an issue: GitHub.