Skip to content

[2.x] fix: Start server when explicitly requested via BSP/thin client#8529

Merged
eed3si9n merged 1 commit intosbt:developfrom
MkDev11:fix/bsp-autoStartServer-7481
Jan 14, 2026
Merged

[2.x] fix: Start server when explicitly requested via BSP/thin client#8529
eed3si9n merged 1 commit intosbt:developfrom
MkDev11:fix/bsp-autoStartServer-7481

Conversation

@MkDev11
Copy link
Copy Markdown
Contributor

@MkDev11 MkDev11 commented Jan 14, 2026

Fix: sbt -bsp exits silently when autoStartServer := false

Problem

When users set autoStartServer := false in their build configuration, running sbt -bsp (used by IntelliJ for BSP project import) would silently exit without starting the server. This made it impossible to import projects in IntelliJ when this setting was enabled, with no obvious error message to indicate what went wrong.

This was particularly frustrating because:

  • The failure was silent with no helpful error message
  • Users had no way of knowing that autoStartServer was the culprit
  • The setting name suggests it controls automatic server startup, not all server startup

Root Cause

The autoStartServer setting was being checked even when the server was explicitly requested via the --server flag (which BSP mode uses internally). The original logic in CommandExchange.run() was:

if (autoStartServerSysProp && autoStart) runServer(s)

This meant that when autoStartServer := false, the server would never start - even when explicitly requested by a remote client like IntelliJ's BSP integration.

Solution

The fix distinguishes between automatic and explicit server startup. When sbt is started by a remote client (BSP or thin client via --server flag), the server now starts regardless of the autoStartServer setting:

val startedByRemote = Terminal.startedByRemoteClient
if (autoStartServerSysProp && (autoStart || startedByRemote)) runServer(s)

This preserves the intended behavior of autoStartServer:

  • When set to false, sbt won't automatically start a server during normal interactive use
  • When explicitly requested (via BSP or --server), the server starts as expected

Testing

  • Verified compilation succeeds
  • The fix is minimal and surgical - only one condition changed
  • The Terminal.startedByRemoteClient flag is already used elsewhere in the codebase for similar purposes

Related

Fixes #7481


Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=94194147

Fixes sbt#7481

When sbt is started by a remote client (BSP or thin client via --server flag),
always start the server regardless of autoStartServer setting. The autoStartServer
setting is meant for automatic server startup, not for blocking explicit server
start requests.
@MkDev11
Copy link
Copy Markdown
Contributor Author

MkDev11 commented Jan 14, 2026

@eed3si9n please review the PR when you are available.

@eed3si9n eed3si9n changed the title fix: Start server when explicitly requested via BSP/thin client [2.x] fix: Start server when explicitly requested via BSP/thin client Jan 14, 2026
Copy link
Copy Markdown
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@eed3si9n eed3si9n merged commit f85ced4 into sbt:develop Jan 14, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sbt -bsp will exit silently if autoStartServer := false is set

2 participants