{"record":{"id":"4bb83012c213a449","repo":"oraios/serena","slug":"could-not-find-sourcekit-lsp-please-install-it-as","errorCode":null,"errorMessage":"Could not find sourcekit-lsp, please install it as described in https://github.com/apple/sourcekit-lsp#installationAnd make sure it is available on your PATH.","messagePattern":"Could not find sourcekit-lsp, please install it as described in https://github\\.com/apple/sourcekit-lsp#installationAnd make sure it is available on your PATH\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/solidlsp/language_servers/sourcekit_lsp.py","lineNumber":43,"sourceCode":"    def is_ignored_dirname(self, dirname: str) -> bool:\n        # For Swift projects, we should ignore:\n        # - .build: Swift Package Manager build artifacts\n        # - .swiftpm: Swift Package Manager metadata\n        # - node_modules: if the project has JavaScript components\n        # - dist/build: common output directories\n        return super().is_ignored_dirname(dirname) or dirname in [\".build\", \".swiftpm\", \"node_modules\", \"dist\", \"build\"]\n\n    @staticmethod\n    def _get_sourcekit_lsp_version() -> str:\n        \"\"\"Get the installed sourcekit-lsp version or raise error if sourcekit was not found.\"\"\"\n        try:\n            result = subprocess_run([\"sourcekit-lsp\", \"-h\"], capture_output=True, text=True, check=False)\n            if result.returncode == 0:\n                return result.stdout.strip()\n            else:\n                raise Exception(f\"`sourcekit-lsp -h` resulted in: {result}\")\n        except Exception as e:\n            raise RuntimeError(\n                \"Could not find sourcekit-lsp, please install it as described in https://github.com/apple/sourcekit-lsp#installation\"\n                \"And make sure it is available on your PATH.\"\n            ) from e\n\n    def __init__(self, config: LanguageServerConfig, repository_root_path: str, solidlsp_settings: SolidLSPSettings):\n        sourcekit_version = self._get_sourcekit_lsp_version()\n        log.info(f\"Starting sourcekit lsp with version: {sourcekit_version}\")\n\n        super().__init__(\n            config, repository_root_path, ProcessLaunchInfo(cmd=\"sourcekit-lsp\", cwd=repository_root_path), \"swift\", solidlsp_settings\n        )\n        self.request_id = 0\n        self._did_sleep_before_requesting_references = False\n        self._initialization_timestamp: float | None = None\n\n    @override\n    def _document_symbols_cache_fingerprint(self) -> Hashable:\n        normalize_symbol_name_version = 1","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/language_servers/sourcekit_lsp.py#L25-L61","documentation":"The wrapper RuntimeError from _get_sourcekit_lsp_version's except clause: any failure to probe sourcekit-lsp (missing binary, non-zero exit) is normalized to this install-guidance message, chained from the original exception. It indicates the Swift toolchain LSP server is unavailable, so the SourceKit language server cannot start.","triggerScenarios":"Initializing SourceKitLSP when the `sourcekit-lsp` executable is absent from PATH or `sourcekit-lsp -h` exits non-zero; the chained `from e` exception holds the underlying cause.","commonSituations":"Fresh machines without Swift tooling, Docker images lacking swift runtime, minimal Xcode CLT-only installs where sourcekit-lsp ships only with full Xcode, CI runners with restricted PATH.","solutions":["Install the Swift toolchain from swift.org (includes sourcekit-lsp) or full Xcode on macOS.","Ensure the binary resolves: `which sourcekit-lsp`; add the toolchain usr/bin to PATH if not.","Inspect the chained cause (`raise ... from e`) message to distinguish not-found vs non-zero exit.","On Linux CI, use the official swift Docker image which bundles sourcekit-lsp."],"exampleFix":"// before: CI image without swift\nFROM ubuntu:22.04\n// after\nFROM swift:5.10-jammy","handlingStrategy":"try-catch","validationCode":"import shutil\nassert shutil.which(\"sourcekit-lsp\"), \"sourcekit-lsp missing from PATH; install Swift toolchain first\"","typeGuard":"def has_sourcekit_lsp() -> bool:\n    import shutil\n    return shutil.which(\"sourcekit-lsp\") is not None","tryCatchPattern":"try:\n    server = SourceKitLSP(config, repo_root, settings)\nexcept RuntimeError as e:\n    if \"Could not find sourcekit-lsp\" in str(e):\n        print(e.__cause__)  # distinguish not-found vs non-zero exit\n        raise SystemExit(\"Install sourcekit-lsp: https://github.com/apple/sourcekit-lsp#installation\") from e\n    raise","preventionTips":["Use Swift-bundled Docker images (swift:X) on Linux CI.","Run `xcode-select -p` on macOS to confirm a full Xcode is selected.","Inspect the chained __cause__ to diagnose whether the binary is missing or crashing."],"tags":["swift","sourcekit","path","install"],"backgroundTag":"language-server-not-on-path","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}