{"record":{"id":"4ca20985f7a6f832","repo":"chenhg5/cc-connect","slug":"chmod-w","errorCode":null,"errorMessage":"chmod: %w","messagePattern":"chmod: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cc-connect/update.go","lineNumber":430,"sourceCode":"\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tsize, err := io.Copy(tmp, resp.Body)\n\tif err != nil {\n\t\ttmp.Close()\n\t\tos.Remove(tmp.Name())\n\t\treturn \"\", fmt.Errorf(\"write: %w\", err)\n\t}\n\ttmp.Close()\n\n\tfmt.Printf(\"Downloaded %.1f MB\\n\", float64(size)/1024/1024)\n\treturn tmp.Name(), nil\n}\n\nfunc replaceExecutable(target, src string) error {\n\tif err := os.Chmod(src, 0o755); err != nil {\n\t\treturn fmt.Errorf(\"chmod: %w\", err)\n\t}\n\n\t// On Windows, rename over a running exe is not possible directly.\n\t// Move old binary aside, then move new one in.\n\tbackup := target + \".old\"\n\tos.Remove(backup)\n\n\tif err := os.Rename(target, backup); err != nil {\n\t\treturn fmt.Errorf(\"backup old binary: %w\", err)\n\t}\n\n\tif err := copyFile(src, target); err != nil {\n\t\t// Attempt to restore\n\t\tif restoreErr := os.Rename(backup, target); restoreErr != nil {\n\t\t\tslog.Warn(\"update: failed to restore old binary after copy error\", \"error\", restoreErr)\n\t\t}\n\t\treturn fmt.Errorf(\"install new binary: %w\", err)\n\t}","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/update.go#L412-L448","documentation":"Wraps a failed os.Chmod(0755) on the downloaded replacement binary in replaceExecutable. It fires when the temp file cannot be marked executable — unusual filesystems, or the temp file vanished (cleaned by another process).","triggerScenarios":"Thrown at cmd/cc-connect/update.go:430 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that TMPDIR is not on a noexec/odd filesystem","Point TMPDIR to a normal local directory","Retry the update"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}