{"record":{"id":"a56cade6834909d1","repo":"ducaale/xh","slug":"unix-socket-is-not-supported-on-this-platform","errorCode":null,"errorMessage":"--unix-socket is not supported on this platform","messagePattern":"--unix-socket is not supported on this platform","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":383,"sourceCode":"                            }\n                            None\n                        })\n                        .with_context(|| format!(\"Couldn't bind to {:?}\", name_or_ip))?;\n                    log::debug!(\"Resolved {name_or_ip:?} to {ip_addr:?}\");\n                    client = client.local_address(ip_addr);\n                }\n            }\n        };\n    }\n\n    #[cfg(unix)]\n    if let Some(socket_path) = args.unix_socket {\n        client = client.unix_socket(socket_path);\n    }\n\n    #[cfg(not(unix))]\n    if args.unix_socket.is_some() {\n        return Err(anyhow::anyhow!(\n            \"--unix-socket is not supported on this platform\"\n        ));\n    }\n\n    for resolve in args.resolve {\n        client = client.resolve(&resolve.domain, SocketAddr::new(resolve.addr, 0));\n    }\n\n    log::trace!(\"Finalizing reqwest client\");\n    log::trace!(\"{client:#?}\");\n    let client = client.build()?;\n\n    let mut session = match &args.session {\n        Some(name_or_path) => Some(\n            Session::load_session(url.clone(), name_or_path.clone(), args.is_session_read_only)\n                .with_context(|| {\n                    format!(\"couldn't load session {:?}\", name_or_path.to_string_lossy())\n                })?,","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/ducaale/xh/blob/2404aceecc08b0b2d100fedc96f57745cd5904dc/src/main.rs#L365-L401","documentation":"The `--unix-socket` option directs the HTTP client to connect over a Unix domain socket instead of TCP, but this is only implemented on Unix-like platforms. On non-Unix builds (e.g. Windows), `run` checks `args.unix_socket.is_some()` under `#[cfg(not(unix))]` and returns this error instead of silently ignoring the flag.","triggerScenarios":"Invoking `xh --unix-socket /path/to.sock ...` on a platform not compiled as `unix` (typically Windows), or using a Windows-subsystem build where Unix sockets are unavailable.","commonSituations":"Porting shell scripts that talk to Docker's unix socket or local daemons from Linux to Windows; CI matrix runs where the same command is executed on Windows runners.","solutions":["Run the command on a Unix-like platform (Linux/macOS) where Unix domain sockets are supported.","On Windows, use the daemon's TCP endpoint instead of its unix socket and drop the `--unix-socket` flag.","Use WSL on Windows to get a Unix environment for the socket-based call."],"exampleFix":"// before (Windows cmd)\nxh --unix-socket /var/run/docker.sock GET http://localhost/v1.41/version\n// after\nxh GET http://localhost:2375/v1.41/version","handlingStrategy":"validation","validationCode":"# guard in shell scripts:\nif [[ \"$OSTYPE\" != linux* && \"$OSTYPE\" != darwin* ]] && [[ \"$*\" == *--unix-socket* ]]; then\n  echo \"--unix-socket unsupported on this platform\"; exit 1\nfi","typeGuard":null,"tryCatchPattern":"// Rust caller:\nmatch run(args) {\n    Err(e) if e.to_string().contains(\"unix-socket\") => fallback_to_tcp(),\n    other => other,\n}","preventionTips":["Branch on platform before choosing socket vs TCP endpoints in cross-platform scripts.","Prefer the daemon's TCP port in Windows environments.","Use WSL for socket-dependent workflows on Windows."],"tags":["platform","unix-socket","cli","windows"],"backgroundTag":"unsupported-platform","analyzedSha":"2404aceecc08b0b2d100fedc96f57745cd5904dc","analyzedAt":"2026-09-13T19:13:33.814Z","contentChangedAt":"2026-09-13T19:13:33.814Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}