JuliusBrussee/caveman · error

native runtime inspect socket

Error message

native runtime inspect socket: %w

What it means

ServeUnix stats the socket path to decide whether it is live, stale, or absent. If Stat fails with an error other than NotExist, it cannot classify the path and returns "native runtime inspect socket". This keeps the runtime from blindly listening over an un-inspectable path.

Solutions

  1. Check that every directory component of the socket path is traversable (x permission) by the current user
  2. Shorten the socket path (unix sockets are limited to ~104/108 bytes)
  3. Fix or remount a failing filesystem; remove bad symlinks in the path

Example fix

// before (path too long / untraversable)
ServeUnix(ctx, "/very/long/path/.../runtime.sock", rt)
// after
ServeUnix(ctx, filepath.Join(os.TempDir(), "nativeruntime.sock"), rt)
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := os.Stat(socketPath); err != nil && !os.IsNotExist(err) {
	return fmt.Errorf("socket path %s not inspectable: %w", socketPath, err)
}
if len(socketPath) > 100 {
	return errors.New("socket path too long")
}

Try / catch

err := nativeruntime.ServeUnix(ctx, path, rt)
if err != nil {
	var perr *fs.PathError
	if errors.As(err, &perr) {
		// choose a shorter, fully-traversable path
	}
	return err
}

Prevention

When it happens

Trigger: os.Stat(path) returns a non-ENOENT error: permission denied on a parent directory, too many symlinks, I/O error on the filesystem, or path length limits.

Common situations: Socket path deep inside directories the user cannot traverse; broken automounts; excessively long socket paths exceeding the unix socket 108-byte limit on stat of parents.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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

Appendix: source

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

		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()
	defer os.Remove(path)
	if err := os.Chmod(path, 0o600); err != nil {
		return fmt.Errorf("native runtime chmod socket: %w", err)
	}
	go func() {
		<-ctx.Done()
		_ = listener.Close()
	}()
	for {
		conn, err := listener.Accept()
		if err != nil {
			if ctx.Err() != nil {

View on GitHub (pinned to 3ee70a1026)