Skip to content

[2.x] fix: Skip native client for sbt new/init commands#8512

Merged
eed3si9n merged 1 commit intosbt:developfrom
MkDev11:fix/new-command-client-args-7497
Jan 13, 2026
Merged

[2.x] fix: Skip native client for sbt new/init commands#8512
eed3si9n merged 1 commit intosbt:developfrom
MkDev11:fix/new-command-client-args-7497

Conversation

@MkDev11
Copy link
Copy Markdown
Contributor

@MkDev11 MkDev11 commented Jan 13, 2026

Fixes #7497

When running 'sbt --client new scala/scala3.g8', the thin client adds internal commands (sbtCompleteExec, resumeFromFailure, sbtPopOnFailure, sbtReportResult, shell) to the command queue. The new command was appending all remainingCommands to the template arguments, causing Giter8 to fail with 'Unknown argument' errors.

Now filters out these internal sbt commands before passing arguments to the template resolver.

Added unit tests for the filtering logic.


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

@eed3si9n
Copy link
Copy Markdown
Member

eed3si9n commented Jan 13, 2026

Now filters out these internal sbt commands before passing arguments to the template resolver.

This means that sbtn is will launch an sbt session in the current directory. Instead, if sbt new is detected on bash/batch (search for sbt_new=true), we should probably ignore --client, and call the "server", which inside of Main.scala is going to short-circuit and does special thing for new anyway.

@MkDev11 MkDev11 force-pushed the fix/new-command-client-args-7497 branch from 8719821 to c2607c4 Compare January 13, 2026 09:24
@MkDev11
Copy link
Copy Markdown
Contributor Author

MkDev11 commented Jan 13, 2026

Now filters out these internal sbt commands before passing arguments to the template resolver.

This means that sbtn is will launch an sbt session in the current directory. Instead, if sbt new is detected on bash/batch (search for sbt_new=true), we should probably ignore --client, and call the "server", which inside of Main.scala is going to short-circuit and does special thing for new anyway.

Thanks for the suggestion! You're right that handling this at the launcher level is cleaner.

I've updated the PR to skip the native client entirely when sbt new or sbt init is detected. The fix adds an early return in isRunNativeClient() (bash) and the equivalent check in sbt.bat (Windows) - when sbt_new=true, we just use the full JVM instead of the thin client.

This avoids the whole issue of internal commands leaking into the template arguments since the native client path is never taken for these commands.

@MkDev11
Copy link
Copy Markdown
Contributor Author

MkDev11 commented Jan 13, 2026

the CI failure appears to be unrelated to this PR. the NotImplementedError is from a scripted test that uses ??? in its build.sbt to test error handling - that's expected behavior. the launcher script changes only affect the execution path for sbt new/sbt init commands and don't impact the server tests

@eed3si9n eed3si9n changed the title fix: Filter internal sbt commands from new command args [2.x] fix: Skip native client for sbt new/init commands Jan 13, 2026
@MkDev11
Copy link
Copy Markdown
Contributor Author

MkDev11 commented Jan 13, 2026

All passed!

@eed3si9n eed3si9n merged commit d4570e3 into sbt:develop Jan 13, 2026
22 of 23 checks passed
eed3si9n pushed a commit to eed3si9n/sbt that referenced this pull request Jan 17, 2026
@eed3si9n eed3si9n added this to the 1.12.1 milestone Jan 26, 2026
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 native new command crashes with any template

2 participants