-
Notifications
You must be signed in to change notification settings - Fork 132
Fix some cases where AbsolutePath::relative(to: AbsolutePath) would assert on Windows #534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
daveinglis
commented
Dec 9, 2025
- there where a couple case where relative(to:) would assert on windows when a path was long (>260) and when tailing slashes where not removed in some cases.
|
@swift-ci test |
|
@swift-ci test linux |
Sources/TSCBasic/Path.swift
Outdated
| while !substring.isEmpty && substring.utf8.last == UInt8(ascii: "\\") { | ||
| substring = substring.dropLast() | ||
| } | ||
| if !substring.isEmpty && substring.last != ":" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kinda sketchy. The last character being : could be a malformed path, e.g. C:\file.txt:.
Sources/TSCBasic/Path.swift
Outdated
| if !substring.isEmpty && substring.last != ":" { | ||
| // Drop the trailing '\', unless the string path only | ||
| // has '\', and unless the slashes are right after the drive letter. | ||
| path = String(substring) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm - C: and C:\ have completely different meanings. Is this logic preserving the trailing slash in the case where the path is pointing at a drive root?
fa18bdd to
975683d
Compare
…ssert - there where a couple case where relative(to:) would assert on windows when a path was long (>206) and when tailing slashes where not removed in some cases.
975683d to
df81ada
Compare
|
@swift-ci test |
|
@swift-ci test windows |
|
This needs some more work/investigation, seeing some strange crashes in swiftPM that this is causing |