{"record":{"id":"ccb1061992aa60de","repo":"JuliusBrussee/caveman","slug":"native-runtime-mkdir-w","errorCode":null,"errorMessage":"native runtime mkdir: %w","messagePattern":"native runtime mkdir: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/internal/nativeruntime/server_unix.go","lineNumber":37,"sourceCode":"\nfunc dialNativeRuntime(ctx context.Context, home string) (net.Conn, error) {\n\treturn (&net.Dialer{}).DialContext(ctx, \"unix\", SocketPath(home))\n}\n\n// Serve binds runtime transport for current platform.\nfunc Serve(ctx context.Context, home string, runtime *Runtime) error {\n\treturn ServeUnix(ctx, SocketPath(home), runtime)\n}\n\n// ServeUnix exposes one-request-per-connection JSON over a user-only Unix\n// socket. Runtime errors close or fail-open the individual call; they never stop\n// the coding agent or the provider proxy.\nfunc ServeUnix(ctx context.Context, path string, runtime *Runtime) error {\n\tif runtime == nil || runtime.store == nil {\n\t\treturn errors.New(\"native runtime: store is required\")\n\t}\n\tif err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {\n\t\treturn fmt.Errorf(\"native runtime mkdir: %w\", err)\n\t}\n\tif err := os.Chmod(filepath.Dir(path), 0o700); err != nil {\n\t\treturn fmt.Errorf(\"native runtime chmod dir: %w\", err)\n\t}\n\tif _, err := os.Stat(path); err == nil {\n\t\tconn, dialErr := net.DialTimeout(\"unix\", path, 50*time.Millisecond)\n\t\tif dialErr == nil {\n\t\t\t_ = conn.Close()\n\t\t\treturn errors.New(\"native runtime: socket already active\")\n\t\t}\n\t\tif err := os.Remove(path); err != nil {\n\t\t\treturn fmt.Errorf(\"native runtime remove stale socket: %w\", err)\n\t\t}\n\t} else if !os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"native runtime inspect socket: %w\", err)\n\t}\n\tlistener, err := net.Listen(\"unix\", path)\n\tif err != nil {","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/internal/nativeruntime/server_unix.go#L19-L55","documentation":"ServeUnix creates the parent directory of the unix socket path with MkdirAll (mode 0700) before listening. If the OS refuses to create that directory, the error is wrapped as \"native runtime mkdir\". This typically reflects filesystem permission problems on the socket directory path.","triggerScenarios":"os.MkdirAll(filepath.Dir(path), 0o700) fails: parent path not writable, path exists as a regular file, read-only filesystem, or quota/exhausted disk.","commonSituations":"Running as a different user than the home directory owner; HOME misconfigured to a read-only or nonexistent path; a file already exists where the socket directory should be; containers with read-only root filesystems.","solutions":["Check permissions on the parent path (filepath.Dir(SocketPath)) and ensure the current user can write it","Verify HOME/socket path is correct and not pointing at a regular file","Ensure the filesystem is writable (not mounted ro, disk not full)"],"exampleFix":"// before\nServeUnix(ctx, \"/run/locked.sock\", rt) // not writable by user\n// after\nServeUnix(ctx, filepath.Join(os.TempDir(), \"nativeruntime.sock\"), rt) // or fix perms: chmod u+w /run","handlingStrategy":"try-catch","validationCode":"dir := filepath.Dir(socketPath)\nif st, err := os.Stat(dir); err == nil && !st.IsDir() {\n\treturn fmt.Errorf(\"%s exists and is not a directory\", dir)\n}\nif err := os.MkdirAll(dir, 0o700); err != nil {\n\treturn err // fail before calling ServeUnix\n}","typeGuard":null,"tryCatchPattern":"err := nativeruntime.ServeUnix(ctx, path, rt)\nif err != nil {\n\tif pe, ok := err.(*fs.PathError); ok && errors.Is(pe.Err, syscall.EACCES) {\n\t\t// handle permission problem: choose alternate path or fix perms\n\t}\n\treturn err\n}","preventionTips":["Pre-create and own the socket directory as part of installation","Never point the socket path at directories owned by other users","Avoid read-only mounts for runtime state paths"],"tags":["filesystem","mkdir","permissions"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}