**Problem**
Under CPU load, the thin client sometimes loses task output. The channel
started reading before it was subscribed, so an early sbt/attach was
dropped and the command ran on an unattached channel.
**Solution**
Start the channel threads after subscribing it.
Fixes#9834
Generated-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
**Problem**
The accept loop did not catch an exception from onIncomingSocket, so
its thread ended. Nothing closed the server socket, so the path stayed
bound: the server took no further client, and the process kept running.
The socket of the client that failed stayed open too.
**Solution**
Log that client, close its socket, and take the next one. An exception
from accept itself keeps the handling it had, so a socket that is
really broken still ends the loop.
The callback now takes a holder rather than the socket, and calls
AtomicCloseable.release to keep it. The loop closes whatever the
callback left behind.
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
**Problem**
Since Coursier 2.1.25 .m2/settings.xml takes over even when sbtResolvers exists.
**Solution**
Turn off .m2/settings.xml unless explicitly enabled.
**Problem**
Like #9848, some paths still swallow InterruptedException. The
NetworkTerminal request methods block on queue.take, so an
interrupted task thread gets a default value back and loses its
interrupt flag. removeChannel still uses put, and the client's boot
read thread ignores the interrupt meant to stop it.
**Solution**
Restore the flag in NetworkTerminal (in withThread only while the
terminal is open), use add in removeChannel, and stop the read
thread on interrupt. Add tests to NetworkChannelSpec.
Generated-by: Claude Opus 5.5
Co-authored-by: Claude Opus 5.5 <[email protected]>
**Problem**
In the default thin-client mode, writing to System.out or System.err
from an interrupted thread throws InterruptedException and clears the
interrupt flag. NetworkChannel enqueues output with `put` on unbounded
LinkedBlockingQueues, and `put` acquires its lock with
lockInterruptibly(). Logging libraries swallow the exception, so the
interrupt is silently lost and code relying on it can hang.
**Solution**
Use `add` instead of `put` on the unbounded queues. They never block,
so no other behavior changes. Add regression tests to
NetworkChannelSpec.
Fixes issue #9845
Generated-by: Claude Opus 5.5
Problem: The Unix launcher ignores JAVA_HOME and selects Java from PATH when JAVACMD is absent.
Solution: Check JAVA_HOME/bin/java before falling back to PATH while preserving explicit --java-home and JAVACMD precedence.
Fixes#9794
Problem
The scripted pause handler assumes the JVM has a directly attached terminal. System.console() can return null when sbt runs in client-server mode or with redirected streams, causing pause to fail.
Solution
Use scala.io.StdIn.readLine() to read the configured input stream, which supports sbt client input forwarding. Add unit tests for waiting, line consumption, and EOF.
Problem
compileIncremental declares the analysis file and the classes directory
as cache outputs, but not the early (pickle) jar or the early analysis.
A cache hit therefore leaves a subproject with a restored analysis and
no early jar. On the next incremental round Zinc has no jar to merge
scalac's pickles into, so the early jar ends up holding only that
round's TASTy/sig files, afterEarlyOutput(true) fires, and every
downstream subproject is compiled against it and fails with "Not found"
for each upstream type that was not just recompiled.
Solution
- Declare the early jar and the early analysis file as outputs of
compileIncremental when exportPipelining produced them, so a hit
restores them.
- Restored outputs are symlinks into the CAS, and Zinc rewrites the
early jar in place when it merges a round's pickles. Replace a
symlinked early jar by a real copy before Zinc runs so the cached
blob is never modified.
- When a previous analysis exists but the early jar does not (a cache
written before the jar was an output, exportPipelining switched on
for an existing build, a deleted early directory), recompile the
subproject from scratch, which writes a complete jar.
**Problem**
sbt fails to start on openSUSE, since OSTYPE=linux, not linux-gnu.
The startup script tries to add .ZIP extension, and fails to untar native client.
**Solution**
Modified startup script only check that OSTYPE starts with linux, instead of linux-gnu.
Problem
-------
SemanticdbPlugin.compileIncAndCacheSemanticdbTargetRootTask is a cached task
that reads semanticdbTargetRoot as a bare File, so its absolute path is hashed
into the action cache key:
((true,${OUT}/.../classes,${OUT}/.../classes.sbtdir.zip),/tmp/repro/target/out/.../meta)
Every other component of that key is virtualized. This one names one checkout
on one machine, so the entry can never be served to a second checkout, to a
colleague, or to CI. A monorepo we measured had 118 such keys, none of them
reachable across machines.
Fixes#9709
Solution
--------
Read the target root through semanticdbTargetRootVF, following the convention
sourcesVF and resourcesVF already set: an uncached task holding the virtualized
form of a File-typed key, so that a cached task hashes ${OUT}/.../meta rather
than the path behind it. A cached helper would key on the same bare File and
reintroduce the problem one level up.
The scripted test asserts the property the bug breaks: relocating
rootOutputDirectory must leave every key alone, so the second compile is a pure
cache hit. It pins Compile / semanticdbOptions, because -semanticdb-target
carries an absolute path into scalacOptions as well, which is a separate issue
and would otherwise mask this one.
Generated-by: Claude Opus 5
**Problem**
1. On Windows, sbt.bat re-parses its own already-received arguments a second time internally, via call/goto with an unquoted variable splice (call :run !SBT_ARGS!, and similarly for -D/-XX flags, several _SBT_OPTS-sourced flags, and the native-client dispatch path). That extra re-tokenization could let &, |, (, or ) inside an argument escape their quoting and run as separate shell commands.
2. The -D/-XX/-- argument handling spliced the raw argument value into a for /F ... in ("%g%") do ( ... ) construct nested up to four levels deep inside multi-line if blocks. Apparently, that confuses cmd to miscount the parentheses.
**Solution**
1. Call :run without the argument.
2. Avoid for /F
**Problem**
ThisBuild scoped baresettings are treated as a common setting,
which results in duplicate appends etc.
**Solution**
Only treat This-project and ThisProject scoped setting as a common setting.
**Problem**
Channels.newInputStream/newOutputStream share a channel-wide lock,
which would deadlock for a duplex communication.
**Solution**
This implements an alternative DuplexChannels functions that's capable
of duplex communication expected of a "socket".
This also duplicates the Java implementation to the worker app,
so we can use JDK domain socket for forked test communication.
reboot restarts sbt with a fresh state, so the extra plugin sbt files registered in BasicKeys.extraMetaSbtFiles were dropped and their plugins disappeared. Prepend an early(addPluginSbtFile=<path>) command for each registered file to the arguments handed to the restarted sbt, so they are re-registered.
---------
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
**Problem**
Commit c8737b8e4f, "refactor: Change the test type" (PR #8181, Eugene Yokota), made Tests.Output and SuiteResult private[sbt] while changing test tasks to return TestResult. The stated rationale was to type test tasks; it did not describe restricting TestResultLogger customization.
TestResultLogger remains a public, documented extension point, but its run method accepts Tests.Output. External plugins consequently cannot implement it in source. This was noticed while working on TW-102637.
**Solution**
Restore public visibility for Tests.Output, SuiteResult, and its companion. Add a scripted external-build regression test that implements TestResultLogger, uses Output.events as Iterable[SuiteResult], runs test, and observes the logger.
---------
Co-authored-by: Codex <[email protected]>
TestRunner now calls endGroup(name, error) before rethrowing an otherwise escaping LinkageError. This completes the TestReportListener lifecycle while preserving the original error propagation and non-zero task result.
Previously, the outer suite catch handled only NonFatal errors. A suite failing with ExceptionInInitializerError could therefore start a listener group and terminate without a terminal callback, forcing integrations to infer failure from rendered output. The direct TestRunner regression checks the error callback, absence of a normal result callback, and rethrow of the same error.
Co-authored-by: Codex <[email protected]>
**Problem**
CompileInputs2.sources and packageBin / mappings are hashed positionally but arrive in
filesystem traversal order, which differs between APFS, ext4 and overlayfs. Two machines
hash an identical tree into different cache keys and cannot use each other's entries.
**Solution**
Sort sourcesVF by virtualized id, and mappings where packageConfigurationTask reads
it. Both are where the keys are built, so nothing appended later escapes the sort.
Generated-by: Claude Opus 5
Both compileOptions sites mapped the whole classpath through
converter.toPath -> converter.toVirtualFile. Going through toPath
defeats FileConverter.toVirtualFile(VirtualFileRef), which already
returns the ref unchanged when it is a VirtualFile, so every entry was
rebuilt from scratch. For a class directory that means walking the
entire output tree, once per dependent.
backendOutput is converted explicitly because it is a settingKey
evaluated once at project load, so reusing it would pin the listing
taken before anything compiled.
Co-authored-by: Claude Opus 5 <[email protected]>
Problem: -V is consumed by the launcher instead of sbt in sbt tasks -V.
Solution: in the parser's -V behavior, lookback to see if there are commands going before it, in which case, forward -V to sbt.
Co-authored-by: Anatolii Kmetiuk <[email protected]>
Add a resolvedScalacOptions task that resolves cache placeholders in scalacOptions to absolute machine paths.
Co-authored-by: azdrojowa123 <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Only rewrite generated plugin descriptors when their normalized lines change, preserving the descriptor timestamp and downstream cache inputs for unchanged plugin discovery.
Add unit coverage plus direct packageBin and assembly Scripted scenarios. The descriptor regressions fail with the former unconditional write and pass with this change; the packageBin fixture also preserves SBT 2’s existing cache-hit behavior.
Co-authored-by: Codex <[email protected]>
**Problem**
CrossVersion(module, scalaModuleInfo) is handed everything needed to name an
artifact, including ScalaModuleInfo.platform, and the name it returns is what
a caller publishes or resolves under. Nothing covers what it does with the
platform.
**Solution**
Name the artifact in full: platform suffix before cross suffix, matching the
coordinate (sbt/sbt#9117), through addPlatformSuffix, which already knows that
jvm contributes no suffix.
Generated-by: Claude Opus 5
Co-authored-by: Albert Meltzer <[email protected]>