[2.x] fix: Only disable symlinks when truly not supported#8479
Merged
eed3si9n merged 1 commit intosbt:developfrom Jan 11, 2026
Merged
[2.x] fix: Only disable symlinks when truly not supported#8479eed3si9n merged 1 commit intosbt:developfrom
eed3si9n merged 1 commit intosbt:developfrom
Conversation
Fix issue where symlinkSupported flag was incorrectly set to false when any FileSystemException occurred during symlink creation. Root cause: FileAlreadyExistsException (a subclass of FileSystemException) was being caught and incorrectly disabling symlinks permanently. The fix: - Only set symlinkSupported=false when the exception message indicates symlinks aren't supported (privilege/permission issues) - FileAlreadyExistsException and other transient errors now fall back to copy without permanently disabling symlinks - Add check that CAS file exists before attempting symlink creation Fixes sbt#8478 Generated-by: Cascade (AI pair programmer)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: Only disable symlinks when truly not supported
What's the problem?
When you delete the disk cache while sbt is running and then recompile, symlinks stop being created. Instead, sbt copies files directly. This happens because the
symlinkSupportedflag gets permanently set tofalseduring the session.As @azdrojowa123 discovered through debugging, a
FileAlreadyExistsExceptionis thrown during step 5 of the reproduction, and this incorrectly disables symlink support.Why does this happen?
The current code catches any
FileSystemExceptionand assumes it means "symlinks aren't supported on this system." ButFileAlreadyExistsExceptionis a subclass ofFileSystemException, and it has nothing to do with symlink support - it just means the file already exists (likely a race condition).What's the fix?
Instead of disabling symlinks on any
FileSystemException, we now only disable them when the error message specifically indicates a permission or privilege issue:This way, transient errors like
FileAlreadyExistsExceptionwill fall back to copying the file, but won't permanently disable symlinks for the rest of the session.I also added a check to verify the CAS file exists before attempting to create a symlink, which helps avoid some edge cases.
Fixes #8478
Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=94194147