Skip to content

[2.x] fix: Fix sbtopts files priority in sbt launch script#8514

Merged
eed3si9n merged 11 commits intosbt:developfrom
mohansinghi:fix/sbtopts-priority-7179
Jan 13, 2026
Merged

[2.x] fix: Fix sbtopts files priority in sbt launch script#8514
eed3si9n merged 11 commits intosbt:developfrom
mohansinghi:fix/sbtopts-priority-7179

Conversation

@mohansinghi
Copy link
Copy Markdown
Contributor

Problem

Project-level .sbtopts settings were being overridden by distribution defaults because the script loaded files in the wrong order. Since Java processes duplicate -D properties left-to-right (last wins), project options appearing first were overridden.

Solution

  1. Reordered loading: dist → machine → project (was: machine/else dist → project)
  2. Changed project .sbtopts from prepend to append so it appears last and wins

Changes

  • Modified /sbt script lines 854-862
  • Project .sbtopts now appended instead of prepended

Testing

Verified that project-level config now correctly overrides machine-wide config:

  • Command line shows: machine-config first, project-local last
  • Java system property reads: project-local

Fixes #7179


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

mohansinghi and others added 2 commits January 13, 2026 14:55
- Reorder sbtopts file loading: dist → machine → project
- Change project .sbtopts from prepend to append so it appears last
- Project-level .sbtopts now correctly overrides machine-wide configs
- Fixes issue where project options were overridden by dist defaults
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 for working on this issue!

Could you add tests in launcher-package/integration-test/src/test/scala/RunnerScriptTest.scala please?

- Add three integration tests to verify sbtopts priority order
- Test that project .sbtopts overrides dist sbtopts
- Test that project .sbtopts overrides machine sbtopts
- Test that project .sbtopts overrides both dist and machine sbtopts
- Make retry and javaBinDir protected in ShellScriptUtil for test access
- Restore if-else structure (only one of machine or dist is read)
- Change from prepend to append for machine/dist sbtopts
- Project .sbtopts still appended last to win for duplicate properties
@mohansinghi mohansinghi requested a review from eed3si9n January 13, 2026 15:55
@mohansinghi
Copy link
Copy Markdown
Contributor Author

@eed3si9n Thank you for your feedback, I have added test, and reverted .sbtopts file.
Please review again.

- Extend testOutput to support distSbtoptsContents and machineSbtoptsContents
- Refactor sbtopts priority tests to use testOutput pattern
- Remove unused imports from RunnerScriptTest
- Follow existing test patterns as requested by reviewer
@mohansinghi mohansinghi requested a review from eed3si9n January 13, 2026 16:16
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!

- Move sbtHome and configHome declarations outside try block
- Update vararg syntax from : _* to * for Scala 3 compatibility
@mohansinghi mohansinghi requested a review from eed3si9n January 13, 2026 16:26
@mohansinghi mohansinghi force-pushed the fix/sbtopts-priority-7179 branch from 4e3118b to da1ae09 Compare January 13, 2026 16:27
@mohansinghi
Copy link
Copy Markdown
Contributor Author

@eed3si9n I have fixed issues on testing. Please review again..

mohansinghi and others added 3 commits January 13, 2026 08:32
- Set XDG_CONFIG_HOME to empty temp directory when testing dist-only
- This prevents script from finding machine sbtopts and ensures dist is loaded
- Add assertions to verify dist sbtopts file is created correctly
- When machine sbtopts exists, script only loads machine (not dist) due to if-else
- Update test to expect only machine and project, not dist
- This matches the actual script behavior
@mohansinghi
Copy link
Copy Markdown
Contributor Author

@eed3si9n I tested on my local, and fixed all issues.
image

Could you please review again?

- Copy entire sbt staging directory to temporary location when testing dist sbtopts
- Use copied script instead of modifying staging directory
- Addresses reviewer feedback about not modifying staging directory
@mohansinghi mohansinghi requested a review from eed3si9n January 13, 2026 17:19
@mohansinghi
Copy link
Copy Markdown
Contributor Author

👍

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 sbtopts files priority in sbt launch script (fixes #7179) [2.x] fix: Fix sbtopts files priority in sbt launch script Jan 13, 2026
@eed3si9n eed3si9n merged commit bb02c33 into sbt:develop Jan 13, 2026
14 checks passed
@eed3si9n
Copy link
Copy Markdown
Member

I created an issue to backport this PR to 1.12.x branch, if you're up for it - #8519

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.

wrong sbt script sbtopts files proiority

2 participants