From 9a88793f7d5ab314c6b75cd076aa24dce506c2ae Mon Sep 17 00:00:00 2001 From: Alberto Simoes <104087721+cx-alberto-simoes@users.noreply.github.com> Date: Tue, 24 Feb 2026 07:31:29 +0000 Subject: [PATCH] - Require coursier only if metals is not found - Before looking for metals in the serena lsp folder, search for it globally --- .../language_servers/scala_language_server.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/solidlsp/language_servers/scala_language_server.py b/src/solidlsp/language_servers/scala_language_server.py index ee500db7..563806cd 100644 --- a/src/solidlsp/language_servers/scala_language_server.py +++ b/src/solidlsp/language_servers/scala_language_server.py @@ -197,6 +197,12 @@ class ScalaLanguageServer(SolidLanguageServer): """ assert shutil.which("java") is not None, "JDK is not installed or not in PATH." + # Check if metals is available globally in PATH + global_metals = shutil.which("metals") + if global_metals: + log.info(f"Found metals in PATH: {global_metals}") + return [global_metals] + # Get settings using the shared helper function settings = _get_scala_settings(solidlsp_settings) metals_version: str = settings["metals_version"] # type: ignore[assignment] @@ -205,11 +211,12 @@ class ScalaLanguageServer(SolidLanguageServer): metals_home = os.path.join(cls.ls_resources_dir(solidlsp_settings), "metals-lsp") os.makedirs(metals_home, exist_ok=True) metals_executable = os.path.join(metals_home, metals_version, "metals") - coursier_command_path = shutil.which("coursier") - cs_command_path = shutil.which("cs") - assert cs_command_path is not None or coursier_command_path is not None, "coursier is not installed or not in PATH." if not os.path.exists(metals_executable): + coursier_command_path = shutil.which("coursier") + cs_command_path = shutil.which("cs") + assert cs_command_path is not None or coursier_command_path is not None, "coursier is not installed or not in PATH." + if not cs_command_path: assert coursier_command_path is not None log.info("'cs' command not found. Trying to install it using 'coursier'.")