{"record":{"id":"ccb1061992aa60de","repo":"JuliusBrussee/caveman","slug":"native-runtime-mkdir-w","errorCode":null,"errorMessage":"native runtime mkdir: %w","messagePattern":"native runtime mkdir: %w","errorType":"console","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/27d5a3981a347890211bb1bf2439e5c821a63bc9/proxy/internal/nativeruntime/server_unix.go#L19-L55","documentation":"ServeUnix prepares the parent directory of the Unix socket path (MkdirAll 0700) before listening for the native runtime's one-request-per-connection JSON service. Failure means the socket directory cannot be created: a path component exists as a file, permission denied along the path, or the filesystem is read-only.","triggerScenarios":"SocketPath(home) dir (e.g. <home>/runtime) occupied by a regular file; home unwritable for the service user; XDG/runtime dir on a read-only mount.","commonSituations":"Running the runtime as a system service with a restricted HOME; leftover artifact occupying the socket dir; containerized deployment with read-only layers.","solutions":["Remove/repair any file occupying the socket directory path","Ensure the running user can create the directory (fix ownership/permissions along the path)","Point the socket path at a writable tmpfs or runtime volume"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func socketDirReady(p string) error {\n    dir := filepath.Dir(p)\n    if fi, err := os.Stat(dir); err == nil {\n        if !fi.IsDir() { return fmt.Errorf(\"%s is not a directory\", dir) }\n    } else if !os.IsNotExist(err) {\n        return err\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-create the socket directory (0700, service-user owned) in unit files","Use a per-user runtime dir like $XDG_RUNTIME_DIR/caveman","Keep the path clear of leftover files from prior installs"],"tags":["unix-socket","filesystem","permissions","nativeruntime","startup"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}