{"record":{"id":"0a03822a0bb5bbb9","repo":"hasura/graphql-engine","slug":"rename-new-to-exe-w","errorCode":null,"errorMessage":"rename new to exe: %w","messagePattern":"rename new to exe: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/update/update.go","lineNumber":185,"sourceCode":"\t// rename the new binary as the current binary\n\terr = os.Rename(newExe, exe)\n\tif err != nil {\n\t\t// rename unsuccessful\n\t\t//\n\t\t// The filesystem is now in a bad state. We have successfully\n\t\t// moved the existing binary to a new location, but we couldn't move the new\n\t\t// binary to take its place. That means there is no file where the current executable binary\n\t\t// used to be!\n\t\t// Try to rollback by restoring the old binary to its original path.\n\t\trerr := os.Rename(oldExe, exe)\n\t\tif rerr != nil {\n\t\t\t// rolling back failed, ask user to re-install cli\n\t\t\treturn errors.E(op, fmt.Errorf(\n\t\t\t\t\"rename old to exe: inconsistent state, re-install cli: %w\",\n\t\t\t\trerr))\n\t\t}\n\t\t// rolled back, throw update error\n\t\treturn errors.E(op, fmt.Errorf(\"rename new to exe: %w\", err))\n\t}\n\n\t// rename success, remove the old binary\n\terrRemove := os.Remove(oldExe)\n\n\t// windows has trouble removing old binaries, so hide it instead\n\t// it will be removed next time this code runs.\n\tif errRemove != nil {\n\t\t_ = hideFile(oldExe)\n\t}\n\n\treturn nil\n}\n\n// Returns an absolute path that can be used to\n// re-invoke the current program.\nfunc getExecutablePath() (string, error) {\n\texecPath, err := os.Executable()","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/update/update.go#L167-L203","documentation":"In ApplyUpdate's swap sequence, the current binary was successfully renamed to '<exe>.old' but the following os.Rename(newExe, exe) failed (cli/update/update.go:185). The code attempts to roll back by restoring the old binary; if rollback succeeds this exact error is returned (the installation is consistent again), and if rollback fails you get error 495 instead.","triggerScenarios":"ApplyUpdate where the downloaded '.<exe>.new' file cannot be renamed over the exe path: destination locked by another process, .new file removed/quarantined, or permission changed after the first rename.","commonSituations":"Windows file locking (running process or antivirus holds the exe path); the .new binary being flagged and quarantined; running the update from a shell whose working state interferes with the swap.","solutions":["Your installation was rolled back — verify the old binary works (cli --version), then fix the cause (permissions/antivirus) and retry the update.","On Windows, exclude the install directory from antivirus and close other instances of the CLI before updating.","Check the '.<exe>.new' file exists and is executable after the failure; delete leftovers before retrying.","If it recurs, update manually: download the release binary and replace the file yourself."],"exampleFix":"# before\n$ cli update\n# error: rename new to exe: file in use\n\n# after\n$ (close all cli instances / disable AV realtime scan)\n$ rm -f /usr/local/bin/.cli.new /usr/local/bin/cli.old\n$ cli update","handlingStrategy":"fallback","validationCode":"if _, err := os.Stat(newExe); err != nil {\n    return fmt.Errorf(\"downloaded binary missing before swap: %s\", newExe)\n}","typeGuard":null,"tryCatchPattern":"if err := update.ApplyUpdate(v); err != nil {\n    if strings.Contains(err.Error(), \"rename new to exe\") && !strings.Contains(err.Error(), \"inconsistent\") {\n        // rollback succeeded; current binary is still the old working one\n        log.Printf(\"update rolled back, still on previous version: %v\", err)\n    }\n    return err\n}","preventionTips":["Close all running instances of the CLI before updating.","Exclude the install dir from antivirus scanning on Windows.","Retry the update once after cleaning .new/.old leftovers."],"tags":["go","self-update","rename","windows","file-lock"],"backgroundTag":"file-rename-permission-denied","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}