{"record":{"id":"4fcd1270dd90b69d","repo":"unslothai/unsloth","slug":"failed-to-spawn-sd-server-self-spawn-error","errorCode":null,"errorMessage":"failed to spawn sd-server: {self._spawn_error}","messagePattern":"failed to spawn sd-server: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"studio/backend/core/inference/sd_cpp_server.py","lineNumber":276,"sourceCode":"                self._process = proc\n                self.port = port\n                adopt_pid(proc.pid)  # so a global shutdown sweep also reaps it\n                spawned.set()\n                self._drain_stdout(proc)\n                # stdout closed == process exited; reap it so it is not left a zombie.\n                try:\n                    proc.wait(timeout = 5)\n                except Exception:  # noqa: BLE001\n                    pass\n\n            self._stdout_thread = threading.Thread(\n                target = _own_process, daemon = True, name = \"sd-server-owner\"\n            )\n            self._stdout_thread.start()\n            spawned.wait()\n            if self._spawn_error is not None:\n                self._dispose()\n                raise RuntimeError(f\"failed to spawn sd-server: {self._spawn_error}\")\n            if not self._wait_ready(startup_timeout):\n                tail = _diagnostic_tail(self._tail, keep = 30)\n                aborted = self._abort.is_set()\n                self._kill_locked()\n                self._dispose()\n                if aborted:\n                    raise SdCppCancelled(\"sd-server startup was cancelled.\")\n                raise RuntimeError(\"sd-server failed to become ready. Last output:\\n\" + tail[:2000])\n\n    def _wait_ready(\n        self,\n        timeout: float,\n        interval: float = 0.5,\n    ) -> bool:\n        \"\"\"Poll ``/v1/models`` until 200; bail early if the process exits.\n\n        Upstream binds the port only AFTER the model is loaded, so a 200 here is a true\n        ready signal (no half-loaded race).\"\"\"","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/sd_cpp_server.py#L258-L294","documentation":"Raised when the background thread that spawns the sd-server process records a spawn error (exec failure, missing binary, permission denied). The wrapper disposes the half-started process and surfaces the underlying spawn error string. This happens before any readiness polling — the process never came up.","triggerScenarios":"Starting the sd-server wrapper when its binary path is missing, not executable, or fails to exec (bad ELF, wrong architecture, missing shared libraries at exec time).","commonSituations":"Broken or partial runtime install after a failed update; binary replaced by a non-executable file; running on an OS/arch the build does not support.","solutions":["Read the {self._spawn_error} part — it is the OS-level reason (ENOENT, EACCES, etc.).","ENOENT/EACCES: restore the binary (`unsloth studio update`) or fix the executable bit and interpreter availability.","Loader errors: install the paired native libraries the server ships with; do not copy the binary out of its bundle directory."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"binary = find_server_binary()\nif binary is None or not os.access(binary, os.X_OK):\n    raise SystemExit(\"sd-server binary missing or not executable; run unsloth studio update\")","typeGuard":null,"tryCatchPattern":"try:\n    server.start()\nexcept RuntimeError as e:\n    if \"failed to spawn\" in str(e):\n        reinstall_runtime(); server.start()\n    raise","preventionTips":["Validate the server binary exists and is executable before starting.","Keep the runtime bundle installed via the updater, not by hand.","Log the spawn_error fragment — it is the OS-level cause."],"tags":["diffusion","sd-cpp","server","process-spawn"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}