JuliusBrussee/caveman · error

native runtime mkdir

Error message

native runtime mkdir: %w

What it means

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.

Solutions

  1. Check permissions on the parent path (filepath.Dir(SocketPath)) and ensure the current user can write it
  2. Verify HOME/socket path is correct and not pointing at a regular file
  3. Ensure the filesystem is writable (not mounted ro, disk not full)

Example fix

// before
ServeUnix(ctx, "/run/locked.sock", rt) // not writable by user
// after
ServeUnix(ctx, filepath.Join(os.TempDir(), "nativeruntime.sock"), rt) // or fix perms: chmod u+w /run
Defensive patterns

Strategy: try-catch

Validate before calling

dir := filepath.Dir(socketPath)
if st, err := os.Stat(dir); err == nil && !st.IsDir() {
	return fmt.Errorf("%s exists and is not a directory", dir)
}
if err := os.MkdirAll(dir, 0o700); err != nil {
	return err // fail before calling ServeUnix
}

Try / catch

err := nativeruntime.ServeUnix(ctx, path, rt)
if err != nil {
	if pe, ok := err.(*fs.PathError); ok && errors.Is(pe.Err, syscall.EACCES) {
		// handle permission problem: choose alternate path or fix perms
	}
	return err
}

Prevention

When it happens

Trigger: os.MkdirAll(filepath.Dir(path), 0o700) fails: parent path not writable, path exists as a regular file, read-only filesystem, or quota/exhausted disk.

Common situations: 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.

Understand the failure class

Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/ccb1061992aa60de. Report an issue: GitHub.

Appendix: source

Thrown at proxy/internal/nativeruntime/server_unix.go:37

func dialNativeRuntime(ctx context.Context, home string) (net.Conn, error) {
	return (&net.Dialer{}).DialContext(ctx, "unix", SocketPath(home))
}

// Serve binds runtime transport for current platform.
func Serve(ctx context.Context, home string, runtime *Runtime) error {
	return ServeUnix(ctx, SocketPath(home), runtime)
}

// ServeUnix exposes one-request-per-connection JSON over a user-only Unix
// socket. Runtime errors close or fail-open the individual call; they never stop
// the coding agent or the provider proxy.
func ServeUnix(ctx context.Context, path string, runtime *Runtime) error {
	if runtime == nil || runtime.store == nil {
		return errors.New("native runtime: store is required")
	}
	if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
		return fmt.Errorf("native runtime mkdir: %w", err)
	}
	if err := os.Chmod(filepath.Dir(path), 0o700); err != nil {
		return fmt.Errorf("native runtime chmod dir: %w", err)
	}
	if _, err := os.Stat(path); err == nil {
		conn, dialErr := net.DialTimeout("unix", path, 50*time.Millisecond)
		if dialErr == nil {
			_ = conn.Close()
			return errors.New("native runtime: socket already active")
		}
		if err := os.Remove(path); err != nil {
			return fmt.Errorf("native runtime remove stale socket: %w", err)
		}
	} else if !os.IsNotExist(err) {
		return fmt.Errorf("native runtime inspect socket: %w", err)
	}
	listener, err := net.Listen("unix", path)
	if err != nil {

View on GitHub (pinned to 3ee70a1026)