JuliusBrussee/caveman · error
native runtime chmod dir
Error message
native runtime chmod dir: %w
What it means
After creating the socket parent directory, ServeUnix explicitly Chmods it to 0700 so only the current user can access the socket. Failure to set this permission is wrapped as "native runtime chmod dir". It enforces the security boundary between the runtime and other local users.
Solutions
- Take ownership of the socket directory: chown/chmod it so the runtime user can set 0700
- Remove the stale directory created by another user and let ServeUnix recreate it
- Use a socket path on a local filesystem that supports permission changes
Example fix
// shell fix, then rerun sudo chown -R "$USER" ~/.caveman && chmod 700 ~/.caveman
Defensive patterns
Strategy: try-catch
Validate before calling
dir := filepath.Dir(socketPath)
if st, err := os.Stat(dir); err != nil {
return err
} else if st.Mode().Perm() != 0o700 {
os.Chmod(dir, 0o700) // normalize beforehand
} Try / catch
if err := nativeruntime.ServeUnix(ctx, path, rt); err != nil {
if strings.Contains(err.Error(), "chmod dir") {
// fall back to a fresh user-owned temp dir
path = filepath.Join(os.TempDir(), "nativeruntime.sock")
return nativeruntime.ServeUnix(ctx, path, rt)
}
return err
} Prevention
- Always run the runtime as the same user that owns the socket directory
- Avoid network filesystems (NFS/CIFS) for socket paths
- Reset directory ownership after running setup as root
When it happens
Trigger: os.Chmod(filepath.Dir(path), 0o700) returns an error: the directory is owned by another user, the filesystem does not support chmod (some network mounts), or the process lacks ownership.
Common situations: Socket directory created earlier by root or another account; NFS/CIFS or Windows-mounted filesystems where chmod is unsupported; running the runtime under a service account after a manual setup as root.
Understand the failure class
Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.
Related errors
- cannot persist MCP ownership journal at
- create
- native runtime chmod socket
- native runtime mkdir
- native session key chmod dir
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/15a6e596400e3c9d.
Report an issue: GitHub.
Appendix: source
Thrown at proxy/internal/nativeruntime/server_unix.go:40
}
// 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 {
return fmt.Errorf("native runtime listen: %w", err)
}
defer listener.Close()View on GitHub (pinned to 3ee70a1026)