{"record":{"id":"dfc03bdd8717c48e","repo":"chenhg5/cc-connect","slug":"cannot-detect-working-directory-w","errorCode":null,"errorMessage":"cannot detect working directory: %w","messagePattern":"cannot detect working directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"daemon/manager.go","lineNumber":135,"sourceCode":"\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 {\n\t\tcfg.LogMaxSize = DefaultLogMaxSize\n\t}\n\tif cfg.LogMaxBackups < 1 {\n\t\tcfg.LogMaxBackups = DefaultLogMaxBackups\n\t}\n\tif cfg.EnvPATH == \"\" {\n\t\tcfg.EnvPATH = os.Getenv(\"PATH\")\n\t}\n\tif len(cfg.EnvExtra) == 0 {\n\t\tcfg.EnvExtra = captureDaemonEnv(cfg.NoCaptureSecrets)\n\t\tif !cfg.NoCaptureSecrets {","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/daemon/manager.go#L117-L153","documentation":"daemon.Resolve defaults cfg.WorkDir to the current working directory via os.Getwd(). This error is returned when Getwd fails — typically because the current directory has been deleted or the process has no readable path to it.","triggerScenarios":"Calling Resolve with an empty WorkDir while the process's working directory was removed (e.g. the parent dir was deleted while the shell sat in it), or when permission changes make the cwd path unresolvable.","commonSituations":"Running `cc-connect daemon install` from a directory that was deleted or renamed in another terminal; running from a temp dir that got cleaned up; restricted sandbox losing access to cwd.","solutions":["cd to an existing directory (e.g. your home dir) and re-run the install command.","Set WorkDir explicitly in the daemon Config instead of relying on the default.","Recreate the deleted directory, or restart the shell so it lands in a valid cwd."],"exampleFix":"// before (shell sitting in a deleted dir)\n$ cc-connect daemon install   # error: cannot detect working directory\n// after\n$ cd ~ && cc-connect daemon install","handlingStrategy":"fallback","validationCode":"if wd, err := os.Getwd(); err != nil {\n    return fmt.Errorf(\"current directory invalid (%v); cd to an existing dir or set WorkDir\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := daemon.Resolve(cfg); err != nil {\n    if strings.Contains(err.Error(), \"cannot detect working directory\") {\n        home, _ := os.UserHomeDir()\n        cfg.WorkDir = home // explicit fallback\n        err = daemon.Resolve(cfg)\n    }\n    if err != nil { return err }\n}","preventionTips":["Run daemon install from a stable directory like $HOME.","Avoid running install commands from temp or soon-to-be-deleted directories.","Set WorkDir explicitly in the daemon config for reproducible installs.","cd out of any directory before deleting it in another session."],"tags":["daemon","filesystem","install"],"backgroundTag":"directory-not-found","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"}