Scala: bump the default Metals version to 1.6.8 so sbt 2 builds can be imported - #1846
Open
merlinorg wants to merge 2 commits into
Open
Scala: bump the default Metals version to 1.6.8 so sbt 2 builds can be imported#1846merlinorg wants to merge 2 commits into
merlinorg wants to merge 2 commits into
Conversation
Metals 1.6.4 bootstraps sbt-bloop 2.0.17, which publishes an sbt 1 artefact but no sbt 2 one, so on an sbt 2 build `bloopInstall` dies on an unresolvable plugin and no build server is ever started. With no build target Metals falls back to a standalone presentation compiler, so the failure is quiet: queries within a single file still answer, and everything needing the build — cross-file references in particular — silently returns nothing. The failed import also leaves auto-generated `metals.sbt` files behind pinning the unresolvable plugin, which breaks the user's own sbt until they are deleted. Metals 1.6.8 bootstraps sbt-bloop 2.1.1, which is published for sbt 2. It is the current stable Metals release; sbt-bloop has shipped an sbt 2 artefact since 2.0.18. The existing Scala test fixture is an sbt 1 project (sbt.version=1.10.1), so the suite exercises the population this could regress.
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.
Serena's default Metals, 1.6.4, cannot import any sbt 2 build. It bootstraps sbt-bloop 2.0.17, which is published for sbt 1 but not for sbt 2, so
bloopInstalldies on an unresolvable plugin and no build server is ever started. Bumping the default to Metals 1.6.8 — which bootstraps sbt-bloop 2.1.1 — fixes it.The failure mode is quiet rather than loud, which is worth knowing when reading bug reports about it. With no build target, Metals falls back to a standalone presentation compiler, which still answers within a single file; what stops working is everything that needs the build — cross-file references in particular. So the user's experience is "references across files silently return nothing", not an error.
There is also a second-order cost that outlives the session: the failed import leaves auto-generated
metals.sbtfiles behind pinning the unresolvable plugin, so the user's ownsbtis broken afterwards until they find and delete them.Environment
uv tool install -p 3.13 'serena-agent>=1.7.0'), Python 3.13.5metals_versioninls_specific_settingssbt.version=2.0.6), Scala 3.3.8Reproduction
A minimal fixture is enough — four files:
Start Serena on it with no
metals_versionoverride and let Metals import the build. Serena answers the import prompt itself since #1769, so this needs no interaction.Expected
Metals imports the build via
bloopInstall, writes.bloop/*.json, and serves symbols across the project.Actual
bloopInstallfails to resolve the plugin and no build target is ever produced:.bloop/receives no*.jsonconfigs at all, and Metals thereafter logsno build target for: <file>for every file it is asked about. On a real multi-module project this also surfaces asEmpty build targets. Expected at least one build target identifier.One
metals.sbtis left behind perproject/nesting level — two in this fixture, three in a project with a deeper meta-build — each containing:After which the user's own sbt fails on the same unresolvable plugin, until those files are deleted by hand:
Analysis
(My reading, offered as such rather than as established fact.)
sbt plugin coordinates are cross-versioned by sbt version, and sbt-bloop 2.0.17 — which Metals 1.6.4 bootstraps — publishes only the sbt 1 artefact. That is why this is invisible to sbt 1 users and to CI. Checkable on Maven Central without running anything:
sbt-bloop_sbt2_32.0.17sbt-bloop_sbt2_32.0.18sbt-bloop_sbt2_32.1.1sbt-bloop_2.12_1.02.0.17Setting
ls_specific_settings.scala.metals_version: "1.6.8"fixes it completely, which is what identifies the version as the whole cause. On a large sbt 2 monorepo, unchanged but for that one setting, Metals writesaddSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.1.1"), the import completes with 17.bloop/*.jsonconfigs, andfind_referencing_symbolsreturns 7 references across 4 files, 3 of them in files other than the definition's.So a workaround exists and is documented — but it is per-project configuration for what is, for every sbt 2 user, a broken default.
Why 1.6.8 specifically
It is the current stable Metals release (v1.6.8, 2026-07-23); 2.0.0-M16 is a milestone and not a candidate. So this is a bump to latest stable rather than a leap, and it is the version I have been running against a large sbt 2 Scala monorepo for the past week.
Risk
Bounded, and CI should demonstrate it:
.github/workflows/pytest.ymlputsscalainMARKERS_JVM, and the Scala fixture attest/resources/repos/scalais an sbt 1 project (sbt.version=1.10.1). So the existing suite exercises exactly the population this change could regress, against a Metals four patch releases newer than the current default. Anyone who needs the old behaviour keepsmetals_versionas the escape hatch.I have deliberately not touched
test/resources/repos/scalaor added an sbt 2 fixture. That would mean a second CI-visible Scala build and a slower JVM batch, and it seemed better to let you decide whether that is wanted than to bundle it into a version bump. Happy to add one if you would like it.The diff also updates the
metals_versiondefault in the Scala table ofdocs/02-usage/050_configuration.md, which states it explicitly and would otherwise contradict the code.Related
Disclosure
Prepared with the assistance of Claude Code (Claude Opus). I reproduced the failure myself on the environment above, verified every log excerpt, source citation and Maven Central result quoted here, and edited the text. I will answer follow-ups personally.
Checklist
CONTRIBUTING.mdregarding the scope of PRs.CHANGELOG.md, which concisely describes the change.