{"record":{"id":"ee73efb71f329bdf","repo":"xai-org/grok-build","slug":"unix-socket-path-too-long","errorCode":null,"errorMessage":"unix socket path too long: {}","messagePattern":"unix socket path too long: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-fast-worktree/src/nfs/client.rs","lineNumber":579,"sourceCode":"pub struct QuerySnapshot {\n    pub phase: Option<String>,\n    pub declined: Option<String>,\n    pub storage_full: bool,\n    pub unknown: bool,\n    pub mount: Option<MountInfo>,\n}\n\n/// `UnixStream::connect` has no deadline. Non-blocking connect + `poll` so a\n/// socket that exists but is not accepting cannot hang ping/create/remove.\nfn connect_unix(path: &Path, timeout: Duration) -> Result<UnixStream> {\n    let bytes = path.as_os_str().as_bytes();\n    let max_path = {\n        // SAFETY: sockaddr_un is a C POD; zeroed is a valid empty address.\n        let z: libc::sockaddr_un = unsafe { std::mem::zeroed() };\n        z.sun_path.len()\n    };\n    if bytes.len() >= max_path {\n        anyhow::bail!(\"unix socket path too long: {}\", path.display());\n    }\n\n    // SAFETY: AF_UNIX/SOCK_STREAM is a defined socket; the fd is owned below.\n    let fd = unsafe { libc::socket(libc::AF_UNIX, libc::SOCK_STREAM, 0) };\n    if fd < 0 {\n        return Err(std::io::Error::last_os_error()).context(\"socket\");\n    }\n    // SAFETY: `fd` is a socket we just created and exclusively own.\n    let fd = unsafe { OwnedFd::from_raw_fd(fd) };\n    let raw = fd.as_raw_fd();\n    // SAFETY: `raw` is the live socket from `fd`; F_GETFD/F_SETFD/F_GETFL/F_SETFL\n    // on our fd are defined.\n    unsafe {\n        let fd_flags = libc::fcntl(raw, libc::F_GETFD);\n        if fd_flags >= 0 {\n            libc::fcntl(raw, libc::F_SETFD, fd_flags | libc::FD_CLOEXEC);\n        }\n        let fl = libc::fcntl(raw, libc::F_GETFL);","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-fast-worktree/src/nfs/client.rs#L561-L597","documentation":"connect_unix builds a sockaddr_un and can only store sun_path.len() (108 on Linux) bytes of the socket path. If the socket path is at or beyond that limit, the connection cannot even be attempted, so it bails early with the offending path.","triggerScenarios":"Calling client.connect_unix (indirectly via call, or directly in connect_missing_socket_fails_quickly) with a socket path >= ~108 bytes — typically a deeply nested temp/XDG cache directory or long project directory names.","commonSituations":"Rust target/tmp directories under long monorepo paths pushing the daemon socket over 108 chars; running tests under deeply nested CI workspaces; TMPDIR configured to a very long path.","solutions":["Shorten the socket path: configure the daemon/client to use a short path like /tmp/grove.sock or a short XDG_RUNTIME_DIR","Reduce nesting depth of the workspace/checkout so the socket path fits under 108 bytes","Set TMPDIR to a short directory (e.g. /tmp/gt) for builds/tests that create the socket","If you control the library, consider socket-dir-based naming or abstract sockets"],"exampleFix":"// before\nexport TMPDIR=/home/very/long/monorepo/path/target/tmp/sockets\n// after\nexport TMPDIR=/tmp/gt   # keeps socket paths well under sun_path (108 bytes)","handlingStrategy":"validation","validationCode":"use std::os::unix::ffi::OsStrExt;\nfn socket_path_fits(path: &std::path::Path) -> bool {\n    path.as_os_str().as_bytes().len() < 108 // sun_path len on Linux\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep socket directories short (e.g. /tmp/gt or XDG_RUNTIME_DIR)","Avoid deeply nested CI workspaces for builds that create sockets","Validate path length before configuring the daemon socket location"],"tags":["unix-socket","path-length","linux","ipc"],"backgroundTag":"unix-socket-path-too-long","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}