{"record":{"id":"ddad5044088e74f6","repo":"chenhg5/cc-connect","slug":"cannot-detect-binary-path-w","errorCode":null,"errorMessage":"cannot detect binary path: %w","messagePattern":"cannot detect binary path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"daemon/manager.go","lineNumber":124,"sourceCode":"\tif err := json.Unmarshal(data, &m); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &m, nil\n}\n\nfunc RemoveMeta() {\n\tos.Remove(metaPath())\n}\n\nfunc NowISO() string {\n\treturn time.Now().Format(time.RFC3339)\n}\n\nfunc Resolve(cfg *Config) error {\n\tif cfg.BinaryPath == \"\" {\n\t\texe, err := os.Executable()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot detect binary path: %w\", err)\n\t\t}\n\t\treal, err := filepath.EvalSymlinks(exe)\n\t\tif err == nil {\n\t\t\texe = real\n\t\t}\n\t\tcfg.BinaryPath = exe\n\t}\n\tif cfg.WorkDir == \"\" {\n\t\twd, err := os.Getwd()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot detect working directory: %w\", err)\n\t\t}\n\t\tcfg.WorkDir = wd\n\t}\n\tif cfg.LogFile == \"\" {\n\t\tcfg.LogFile = DefaultLogFile()\n\t}\n\tif cfg.LogMaxSize <= 0 {","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/daemon/manager.go#L106-L142","documentation":"daemon.Resolve fills in defaults for the daemon service config. When cfg.BinaryPath is empty, it calls os.Executable(); if the OS cannot determine the current executable's path (os.Executable returns an error), this error wraps that failure.","triggerScenarios":"Calling Resolve with a Config whose BinaryPath is empty on a system where os.Executable() fails — e.g. the binary was deleted/replaced while running, or an exotic environment (procfs unavailable, some containers) where /proc/self/exe cannot be resolved.","commonSituations":"Installing the daemon from a temporary binary that was deleted after start; running in a minimal/restricted container where /proc is not mounted; unusual launch mechanisms that break executable path detection.","solutions":["Set BinaryPath explicitly in the daemon Config (e.g. /usr/local/bin/cc-connect) so detection is skipped.","Ensure /proc is mounted if running in a container (Linux relies on /proc/self/exe).","Reinstall or restore the binary so the running executable exists on disk.","Retry the install from a normally launched shell."],"exampleFix":"// before\ncfg := &daemon.Config{} // BinaryPath empty, detection fails\n// after\ncfg := &daemon.Config{BinaryPath: \"/usr/local/bin/cc-connect\"}","handlingStrategy":"fallback","validationCode":"if _, err := os.Executable(); err != nil && cfg.BinaryPath == \"\" {\n    return fmt.Errorf(\"set BinaryPath explicitly: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := daemon.Resolve(cfg); err != nil {\n    if strings.Contains(err.Error(), \"cannot detect binary path\") {\n        cfg.BinaryPath = \"/usr/local/bin/cc-connect\" // explicit fallback\n        err = daemon.Resolve(cfg)\n    }\n    if err != nil { return err }\n}","preventionTips":["Always set BinaryPath explicitly when installing from scripts or containers.","Avoid installing the daemon from a temp binary that may be deleted.","Ensure /proc is mounted in containers so os.Executable works.","Never delete/replace the running binary without restarting the installer."],"tags":["daemon","filesystem","install"],"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"}