{"record":{"id":"eb383da59122268b","repo":"chenhg5/cc-connect","slug":"get-executable-path-w","errorCode":null,"errorMessage":"get executable path: %w","messagePattern":"get executable path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/updater.go","lineNumber":248,"sourceCode":"\t}\n\tfor _, f := range r.File {\n\t\tname := filepath.Base(f.Name)\n\t\tif strings.HasPrefix(name, \"cc-connect\") && !f.FileInfo().IsDir() {\n\t\t\trc, err := f.Open()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tdefer rc.Close()\n\t\t\treturn io.ReadAll(rc)\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"cc-connect binary not found in zip archive\")\n}\n\nfunc replaceBinary(newBinary []byte) error {\n\texecPath, err := os.Executable()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get executable path: %w\", err)\n\t}\n\texecPath, err = filepath.EvalSymlinks(execPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"resolve symlinks: %w\", err)\n\t}\n\n\tdir := filepath.Dir(execPath)\n\ttmpFile, err := os.CreateTemp(dir, \"cc-connect-update-*\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create temp file: %w\", err)\n\t}\n\ttmpPath := tmpFile.Name()\n\n\tif _, err := tmpFile.Write(newBinary); err != nil {\n\t\ttmpFile.Close()\n\t\tos.Remove(tmpPath)\n\t\treturn fmt.Errorf(\"write new binary: %w\", err)\n\t}","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/updater.go#L230-L266","documentation":"replaceBinary starts by locating the running executable with os.Executable(); if the OS refuses (process image unavailable, exec path deleted mid-run, unsupported environment), the error is wrapped as \"get executable path: %w\". Without the path, self-update cannot proceed safely.","triggerScenarios":"SelfUpdate -> replaceBinary ran while os.Executable() returned an error: the binary file was deleted/renamed while the process ran, the executable was started via a mechanism that doesn't provide /proc/self/exe-style info, memory pressure in syscalls on exotic platforms.","commonSituations":"User deleted the old binary after starting cc-connect (e.g. cleaned install dir while daemon running); running from a tmpfs cleared at runtime; cross-compiling/embedding scenarios where the runtime lacks procfs (some containers with masked /proc).","solutions":["Restart cc-connect from an intact binary path so os.Executable() resolves again — update the freshly installed binary instead.","Check that /proc is mounted if running in a container (mount -t proc proc /proc).","Reinstall the binary to its expected location, then run the update from there.","If you manage deployment externally (package manager), update via that mechanism instead of the in-process self-updater.","If this reproduces on a supported platform with the file present, file a bug with the wrapped errno (the %w cause shows the underlying OS error)."],"exampleFix":"# before: binary removed under a running daemon\nrm /usr/local/bin/cc-connect  # daemon still running\n# after: reinstall, restart, then update\nsudo cp ./cc-connect-new /usr/local/bin/cc-connect && sudo systemctl restart cc-connect","handlingStrategy":"try-catch","validationCode":"p, err := os.Executable()\nif err != nil {\n    return fmt.Errorf(\"cannot self-update: %v\", err)\n}\nif _, err := os.Stat(p); err != nil {\n    return fmt.Errorf(\"running binary missing: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := selfUpdate(); err != nil {\n    if strings.Contains(err.Error(), \"get executable path\") {\n        // fall back to a full reinstall / restart from a valid binary\n    }\n}","preventionTips":["Never delete the running binary; replace it atomically via rename","Restart the daemon before wiping install directories","Run in environments with /proc mounted"],"tags":["filesystem","process","self-update"],"backgroundTag":"file-not-found","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}