Skip to content

Commit

Permalink
fix(linux): detect swift symlinked to bin dir. (#802)
Browse files Browse the repository at this point in the history
Signed-off-by: Julia DeMille <[email protected]>
  • Loading branch information
judemille authored Feb 4, 2024
1 parent 8abd090 commit 93d94e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

##### Bug Fixes

* Fix an issue where the path to the SourceKit library would not be properly
detected on Linux, when the swift executable was symlinked into a directory
in PATH from its actual install tree.
[Julia DeMille](https://github.com/judemille)

* Fix a crash when a file cannot be read as UTF-8.
[Martin Redington](https://github.com/mildm8nnered)
[#765](https://github.com/jpsim/SourceKitten/issues/765)
Expand Down
6 changes: 5 additions & 1 deletion Source/SourceKittenFramework/library_wrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ private extension String {
.reduce(URL(fileURLWithPath: self)) { url, _ in url.deletingLastPathComponent() }
.path
}

func resolvingSymlinksInPath() -> String {
return URL(fileURLWithPath: self).resolvingSymlinksInPath().path
}
}

#if os(Linux)
Expand Down Expand Up @@ -111,7 +115,7 @@ internal let linuxFindSwiftInstallationLibPath: String? = {
}

/// .../bin/swift -> .../lib
return swiftPath.deleting(lastPathComponents: 2).appending(pathComponent: "/lib")
return swiftPath.resolvingSymlinksInPath().deleting(lastPathComponents: 2).appending(pathComponent: "/lib")
}()

/// Fallback path on Linux if no better option is available.
Expand Down

0 comments on commit 93d94e5

Please sign in to comment.