From e0af38c293368f670faa9087cdd5255d2f7de290 Mon Sep 17 00:00:00 2001 From: Barry Friedman Date: Thu, 30 Oct 2025 03:31:36 -0700 Subject: [PATCH] fix: add linux-arm64 support for clangd language server (#712) Add RuntimeDependency entry for linux-arm64 platform with system-installed clangd detection. Since clangd project doesn't provide pre-built ARM64 Linux binaries (unlike macOS which uses universal binaries), users need to install clangd via their system package manager. The fix detects ARM64 Linux systems and uses shutil.which() to find system-installed clangd, providing helpful installation instructions if not found. --------- Co-authored-by: COMEBACKISREAL Co-authored-by: Barry Friedman (friedman) --- .../clangd_language_server.py | 49 +++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/src/solidlsp/language_servers/clangd_language_server.py b/src/solidlsp/language_servers/clangd_language_server.py index 6f1426be..2a1f9e8e 100644 --- a/src/solidlsp/language_servers/clangd_language_server.py +++ b/src/solidlsp/language_servers/clangd_language_server.py @@ -51,6 +51,8 @@ class ClangdLanguageServer(SolidLanguageServer): """ Setup runtime dependencies for ClangdLanguageServer and return the command to start the server. """ + import shutil + deps = RuntimeDependencyCollection( [ RuntimeDependency( @@ -89,21 +91,40 @@ class ClangdLanguageServer(SolidLanguageServer): ) clangd_ls_dir = os.path.join(cls.ls_resources_dir(solidlsp_settings), "clangd") - dep = deps.get_single_dep_for_current_platform() - clangd_executable_path = deps.binary_path(clangd_ls_dir) - if not os.path.exists(clangd_executable_path): - logger.log( - f"Clangd executable not found at {clangd_executable_path}. Downloading from {dep.url}", - logging.INFO, - ) - deps.install(logger, clangd_ls_dir) - if not os.path.exists(clangd_executable_path): - raise FileNotFoundError( - f"Clangd executable not found at {clangd_executable_path}.\n" - "Make sure you have installed clangd. See https://clangd.llvm.org/installation" - ) - os.chmod(clangd_executable_path, 0o755) + try: + dep = deps.get_single_dep_for_current_platform() + except RuntimeError: + dep = None + + if dep is None: + # No prebuilt binary available, look for system-installed clangd + clangd_executable_path = shutil.which("clangd") + if not clangd_executable_path: + raise FileNotFoundError( + "Clangd is not installed on your system.\n" + + "Please install clangd using your system package manager:\n" + + " Ubuntu/Debian: sudo apt-get install clangd\n" + + " Fedora/RHEL: sudo dnf install clang-tools-extra\n" + + " Arch Linux: sudo pacman -S clang\n" + + "See https://clangd.llvm.org/installation for more details." + ) + logger.log(f"Using system-installed clangd at {clangd_executable_path}", logging.INFO) + else: + # Standard download and install for platforms with prebuilt binaries + clangd_executable_path = deps.binary_path(clangd_ls_dir) + if not os.path.exists(clangd_executable_path): + logger.log( + f"Clangd executable not found at {clangd_executable_path}. Downloading from {dep.url}", + logging.INFO, + ) + _ = deps.install(logger, clangd_ls_dir) + if not os.path.exists(clangd_executable_path): + raise FileNotFoundError( + f"Clangd executable not found at {clangd_executable_path}.\n" + + "Make sure you have installed clangd. See https://clangd.llvm.org/installation" + ) + os.chmod(clangd_executable_path, 0o755) return clangd_executable_path @staticmethod