Skip to content

[2.x] fix: handle --script-version sbt 2.x project dirs#8715

Merged
eed3si9n merged 2 commits intosbt:developfrom
Eruis2579:develop
Feb 8, 2026
Merged

[2.x] fix: handle --script-version sbt 2.x project dirs#8715
eed3si9n merged 2 commits intosbt:developfrom
Eruis2579:develop

Conversation

@Eruis2579
Copy link
Copy Markdown
Contributor

What

Fixes #8711: sbt --script-version now works when run from an sbt 2.x project directory.

Problem

From a project with project/build.properties set to sbt 2.x (e.g. sbt.version=2.0.0-RC8), the script defaults to the native client (sbtn). The --script-version flag was only handled inside run() (the JVM launcher path), so when the script took the native client path it never checked --script-version and instead ran sbtn with that flag. sbtn doesn’t implement it, so the user saw "failed to connect to server" instead of the script version.

Solution

Handle --script-version right after process_args and before the isRunNativeClient branch. If print_sbt_script_version is set, print $init_sbt_version and exit, so we never delegate to sbtn for this case.

Testing

  • From repo root (sbt 1.x): ./sbt --script-version → prints _to_be_replaced
  • From sbt 2.x project dir: sbt --script-version → prints _to_be_replaced (no sbtn run)

…x project dirs

When in an sbt 2.x project directory, the script used to delegate to sbtn
before checking --script-version, so 'sbt --script-version' ran sbtn and
failed. Now we print the script version and exit before the native client
branch.
…two test variants

- sbt: remove duplicate --script-version handling from run() (keep only early check)
- ShellScriptUtil: add citestVariant parameter to testOutput (default citest)
- Add launcher-package/citest2 with sbt.version=2.0.0-RC8
- RunnerScriptTest: run --script-version test on citest (1.x) and citest2 (2.x)
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 changed the title Fix #8711: handle --script-version before native client for sbt 2.x project dirs [2.x] fix: handle --script-version sbt 2.x project dirs Feb 8, 2026
@eed3si9n eed3si9n merged commit de2c27a into sbt:develop Feb 8, 2026
15 checks passed
eed3si9n pushed a commit to eed3si9n/sbt that referenced this pull request Feb 14, 2026
When in an sbt 2.x project directory, the script used to delegate to sbtn
before checking --script-version, so 'sbt --script-version' ran sbtn and
failed. Now we print the script version and exit before the native client
branch.
eed3si9n added a commit that referenced this pull request Feb 14, 2026
When in an sbt 2.x project directory, the script used to delegate to sbtn
before checking --script-version, so 'sbt --script-version' ran sbtn and
failed. Now we print the script version and exit before the native client
branch.

Co-authored-by: PandaMan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sbt --script-version doesn't work on sbt 2.x project directories

2 participants