{"record":{"id":"ba5cc0d02d100340","repo":"oraios/serena","slug":"process-terminated-immediately-with-code-process","errorCode":null,"errorMessage":"Process terminated immediately with code {process.returncode}. Error: {error_message}","messagePattern":"Process terminated immediately with code (.+?)\\. Error: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"src/solidlsp/ls_process.py","lineNumber":532,"sourceCode":"\n    def is_running(self) -> bool:\n        return self._process is not None and self._process.returncode is None\n\n    def _start(self) -> None:\n        log.info(\"Starting language server process via command: %s\", self._process_launch_info.cmd)\n\n        process = subprocess_util.ManagedSubprocessLauncher.get_instance().launch(\n            self._process_launch_info, name=f\"LS[{self.ls_id.value}]\", start_new_session=self._start_independent_lsp_process\n        )\n        self._process = process\n\n        # Check if process terminated immediately\n        if process.returncode is not None:\n            log.error(\"Language server has already terminated/could not be started\")\n            # Process has already terminated\n            stderr_data = process.stderr.read() if process.stderr else b\"\"\n            error_message = stderr_data.decode(\"utf-8\", errors=\"replace\")\n            raise RuntimeError(f\"Process terminated immediately with code {process.returncode}. Error: {error_message}\")\n\n        # start threads to read stdout and stderr of the process\n        threading.Thread(\n            target=self._read_ls_process_stdout,\n            name=f\"LSP-stdout-reader:{self.ls_id.value}\",\n            daemon=True,\n        ).start()\n        threading.Thread(\n            target=self._read_ls_process_stderr,\n            name=f\"LSP-stderr-reader:{self.ls_id.value}\",\n            daemon=True,\n        ).start()\n\n    def _stop(self, timeout: float) -> None:\n        if self._process is None:\n            log.debug(\"Server process is None, cannot shutdown.\")\n            return\n","sourceCodeStart":514,"sourceCodeEnd":550,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/ls_process.py#L514-L550","documentation":"RuntimeError raised in _start (src/solidlsp/ls_process.py:532) when the language-server subprocess exits (returncode is not None) immediately after launch. stderr is captured into the message, so the real startup failure reason (bad path, missing runtime, bad CLI flags) is included.","triggerScenarios":"Starting a language server whose executable path doesn't exist, whose runtime (node/java/python) is missing or too old, or which exits at startup due to invalid arguments or version incompatibility.","commonSituations":"Language server not installed or not on PATH; wrong binary path in config; Java/Node version too old for the server; corrupted installation; sandbox/container lacking dependencies.","solutions":["Read the stderr text in the error message — it names the actual startup failure.","Verify the server executable path exists and is executable (e.g. `which <server>`).","Install or reinstall the language server runtime (node, java, dotnet, etc.) at a compatible version.","Check the language server's version against the one expected by the library."],"exampleFix":"// before (server not on PATH)\nSolidLSP(..., ls_specific_settings={\"nodejs_path\": \"/nonexistent/node\"})\n// after\nimport shutil\nassert shutil.which(\"node\"), \"node must be installed and on PATH\"\nSolidLSP(...)","handlingStrategy":"validation","validationCode":"import shutil\nserver = cfg.binary_path\nassert shutil.which(server) or os.path.isfile(server), f\"server binary not found: {server}\"\nassert shutil.which(\"node\") and node_version_at_least(18), \"node >=18 required\"","typeGuard":"def server_binary_ok(path: str) -> bool:\n    return os.path.isfile(path) and os.access(path, os.X_OK)","tryCatchPattern":"try:\n    ls = SolidLSP(cfg)\nexcept RuntimeError as e:\n    if \"Process terminated immediately\" in str(e):\n        log.error(\"LS startup failed, stderr: %s\", e)\n        raise StartupError(str(e)) from e\n    raise","preventionTips":["Pre-check the server executable and runtime versions in setup scripts","Pin language-server versions known to work with the library","Run a startup smoke test in CI before depending on the server","Capture stderr of failed startups — it names the root cause"],"tags":["subprocess","language-server","startup"],"backgroundTag":"process-failed-to-start","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}