Repository navigation
fix: install Metals with Homebrew's coursier too, and give the cpp_ls, docker-language-server and terraform-ls servers the command of the installed file - #2143
Merged
lagergren merged 3 commits intoNov 23, 2026
Conversation
…ly with cs The Metals installer found and ran Coursier only as cs: its check ran `which cs`, and its run `cs install metals --install-dir .`. Homebrew's coursier formula (brew install coursier) installs only coursier, a JAR launcher, and no cs, so a user who installed Coursier that way was told that Coursier is required, and the run, if it ran, failed with `Cannot run program "cs"`. Only `cs setup` and the coursier/formulas tap install cs. The check now looks for cs, and else for coursier (`where` on Windows), before it looks for the Metals launcher, and the run installs Metals with cs if it is there, and else with coursier (`cmd /C coursier` on Windows, for coursier.bat). Both use only the exec, fileExists, showMessage and configureServer tasks, which every version of LSP4IJ knows. Without either command, the message names both, and how to install them: `cs setup`, `brew install coursier`, or `brew install coursier/formulas/coursier`. The template's README and docs/user-defined-ls/metals.md say the same. MetalsInstallerTest runs the bundled installer with an exec task that finds only the given commands on the PATH, on macOS and on Windows. BundledTemplateCommandsTest also checks that a coursier install ignores its standard error.
…server or terraform-ls template the command of the file that is already installed The templates of cpp_ls, docker-language-server and terraform-ls have the command of a server on the PATH (`cpp_ls`, `docker-language-server start --stdio`, `terraform-ls serve`), and their installers download the server into ~/.lsp4ij/lsp/<template> and give it the command of that file. Their check is a fileExists of that file. So a server created from the template once the file is there, as a second server from the template, one created again, or the same template in another JetBrains IDE, which shares ~/.lsp4ij, passed the check, and kept the command of the template: it couldn't start (`Cannot run program "cpp_ls": error=2`), and since the check passed, the installer never gave it the right command. redhat-developer#2089 gave the checks of the other downloaded servers a replaceTemplateCommand with the file that they found, and left these three "with their commands on the PATH". But their installers never put anything on the PATH, and their check doesn't look there: a server on the PATH isn't found, and the downloaded one isn't started. Their checks now replace the command of the template, by OS as in their template.json, with the file that they found, and the arguments that the download gives (`serve`, `start --stdio`), as the other checks do. A command that the user or the download set is kept. An LSP4IJ before 0.30.2 skips the task, which it doesn't know, and keeps the command as before. InstallerTaskRegistryFileExistsTest runs the download of each from a local asset, then the check for a server with the command of the template, and BundledTemplateCommandsTest lists them among the checks that give the command of the download, for each OS and architecture.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2143 +/- ##
==========================================
+ Coverage 53.21% 53.22% +0.01%
==========================================
Files 826 826
Lines 34717 34717
Branches 5423 7143 +1720
==========================================
+ Hits 18475 18479 +4
+ Misses 13472 13466 -6
- Partials 2770 2772 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…hat it runs on
configureServer is LSP4IJ's own task, which gives the command for the OS that the test runs on, so on Windows the run sets "${workingDir}/metals.bat", not the macOS launcher that the test expected.
Collaborator
Author
|
@coderabbitai review |
Action performed
|
This was referenced Nov 23, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please merge with "Rebase and merge", not "Squash and merge". Each commit is one change, and its title names what users will notice, so a rebase merge puts both titles in the release notes.
What
A live run of every bundled installer on macOS found two installer bugs. The run used
testBundledInstallers, a local, opt-in harness that installs the servers for real into a sandbox; it isn't part of this PR.cs.Cause
which cs, and the run runscs install metals --install-dir .. Homebrew'scoursierformula (brew install coursier, 2.1.27) installs onlybin/coursier, a JAR launcher, and nocs; onlycs setupand thecoursier/formulastap installcs. With only Homebrew'scoursieron the PATH, the live run's log shows:cpp_ls,docker-language-server start --stdio,terraform-ls serve). Their installers download the server into~/.lsp4ij/lsp/<template>, and their checks are a barefileExistsof that file.~/.lsp4ij.replaceTemplateCommand, and left these three "on the PATH". But nothing puts them on the PATH, and their check doesn't look there.Change
cs, then forcoursier(where …on Windows), before it looks for the launcher.csif it's there, and otherwise withcoursier(cmd /C coursieron Windows).cs setup,brew install coursier, orbrew install coursier/formulas/coursier. The template's README anddocs/user-defined-ls/metals.mdsay the same.fileExistschecks get anonSuccessreplaceTemplateCommand, as clangd and the others already have. It replaces the template's command, by OS as in each template.json, with"${check.file}"plus the arguments that the download gives (none,start --stdio,serve). A command that the user or an earlier download set is kept.Behaviour changes
coursiertoo, as Homebrew'scoursierformula installs it, not only ascs; without either, its message says how to install Coursier.~/.lsp4ijBackward compatibility
exec,fileExists,showMessageandconfigureServer, so older LSP4IJ versions run it too, with thecoursierfallback.replaceTemplateCommand, which they don't know, so their checks of the three templates behave as before.Test
MetalsInstallerTest(new): it runs the bundled Metals installer with anexecthat finds only the given commands on the PATH, on macOS and on Windows. It covers the check and the run with onlycoursier, with onlycs, with both, and with neither (the message). 6 of its 7 tests fail without the fix; the 7th, the check withcs, guards what stays.InstallerTaskRegistryFileExistsTest: for each of the three templates, it runs a download from a local asset, then the check for a server with the template's command, which must get the download's command; a changed command is kept. All three tests fail without the fix.BundledTemplateCommandsTest: the three templates are inCHECKS_WHICH_GIVE_THE_COMMAND, checked for each OS and architecture, which fails without the fix. Its rule that a package manager's install ignores the standard error also coverscoursier install.initialize, and the next session's check, with only Homebrew'scoursier2.1.27, with only the nativecs2.1.27, and with both. With neither, the check shows the new message, and the installation isn't counted as done.initialize.