{"record":{"id":"58e1e47609d56bf7","repo":"chenhg5/cc-connect","slug":"create-run-dir-w","errorCode":null,"errorMessage":"create run dir: %w","messagePattern":"create run dir: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/api.go","lineNumber":69,"sourceCode":"\tProject    string            `json:\"project\"`\n\tSessionKey string            `json:\"session_key\"`\n\tMessage    string            `json:\"message\"`\n\tWorkDir    string            `json:\"work_dir,omitempty\"`\n\tCWD        string            `json:\"cwd,omitempty\"`\n\tTTSText    string            `json:\"tts_text,omitempty\"`\n\tImages     []ImageAttachment `json:\"images,omitempty\"`\n\tFiles      []FileAttachment  `json:\"files,omitempty\"`\n\tAudios     []FileAttachment  `json:\"audios,omitempty\"`\n\tVideos     []FileAttachment  `json:\"videos,omitempty\"`\n\tAtUsers    []string          `json:\"at_users,omitempty\"`\n\tAtAll      bool              `json:\"at_all,omitempty\"`\n}\n\n// NewAPIServer creates an API server on a Unix socket.\nfunc NewAPIServer(dataDir string) (*APIServer, error) {\n\tsockDir := filepath.Join(dataDir, \"run\")\n\tif err := os.MkdirAll(sockDir, 0o755); err != nil {\n\t\treturn nil, fmt.Errorf(\"create run dir: %w\", err)\n\t}\n\tsockPath := filepath.Join(sockDir, \"api.sock\")\n\n\t// Remove stale socket\n\tos.Remove(sockPath)\n\n\tlistener, err := net.Listen(\"unix\", sockPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"listen unix socket: %w\", err)\n\t}\n\tif err := os.Chmod(sockPath, 0o600); err != nil {\n\t\t_ = listener.Close()\n\t\treturn nil, fmt.Errorf(\"chmod socket: %w\", err)\n\t}\n\n\ts := &APIServer{\n\t\tsocketPath:         sockPath,\n\t\tlistener:           listener,","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/api.go#L51-L87","documentation":"NewAPIServer creates <dataDir>/run to host the API Unix domain socket; if os.MkdirAll fails the error is wrapped as \"create run dir: %w\". This is an mkdir/permission problem on the data directory, not a network issue.","triggerScenarios":"Calling core.NewAPIServer(dataDir) with a dataDir whose parent does not exist and cannot be created (permission denied), or which is read-only, or where a non-directory file already exists at the run path.","commonSituations":"dataDir points to root-owned or read-only location while running as unprivileged user; a plain file named 'run' already exists in dataDir; running in a container with a read-only volume mounted at dataDir.","solutions":["Verify dataDir exists and is writable by the process user (ls -ld <dataDir>; mkdir/chown as needed)","If a file named 'run' exists in dataDir, remove or rename it so MkdirAll can create the directory","Point dataDir at a writable location via configuration/flag (e.g. XDG data dir)","In containers, mount the data dir as a writable volume"],"exampleFix":"// before\nsrv, err := core.NewAPIServer(\"/etc/cc-connect\") // root-owned, read-only\n// after\nsrv, err := core.NewAPIServer(\"/home/user/.local/share/cc-connect\")","handlingStrategy":"validation","validationCode":"if fi, err := os.Stat(dataDir); err != nil {\n    return fmt.Errorf(\"dataDir does not exist or is unreadable: %w\", err)\n} else if !fi.IsDir() {\n    return fmt.Errorf(\"dataDir is not a directory\")\n} else if err := syscall.Access(dataDir, os.O_WRONLY); err != nil {\n    return fmt.Errorf(\"dataDir not writable by current user\")\n}","typeGuard":null,"tryCatchPattern":"srv, err := core.NewAPIServer(dataDir)\nif err != nil {\n    if strings.Contains(err.Error(), \"create run dir\") {\n        slog.Error(\"cannot create run dir; check dataDir ownership/permissions\", \"err\", err)\n    }\n    return err\n}","preventionTips":["Default dataDir to the user's XDG data directory, not /etc or /var","Ensure nothing named 'run' exists as a plain file inside dataDir","Mount writable volumes for dataDir in containers","Check permissions after installing as a different user"],"tags":["filesystem","permissions","unix-socket","go"],"backgroundTag":"mkdir-permission-denied","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"}