Skip to content

Commit b5adc3d

Browse files
committed
Fix logic of SWIFT_DRIVER_TOOLNAME_EXEC override
The previous searching logic doesn't match the description, and will instead fail if the specified path doesn't exist. This commit changes the behavior to fallthrough if the path doesn't exist, similar to legacy driver and SwiftPM.
1 parent 230f3d5 commit b5adc3d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Sources/SwiftDriver/Toolchains/Toolchain.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,9 @@ extension Toolchain {
206206
/// looks in the `executableDir`, `xcrunFind` or in the `searchPaths`.
207207
/// - Parameter executable: executable to look for [i.e. `swift`].
208208
func lookup(executable: String) throws -> AbsolutePath {
209-
if let overrideString = envVar(forExecutable: executableName(executable)) {
210-
return try AbsolutePath(validating: overrideString)
209+
if let overrideString = envVar(forExecutable: executableName(executable)),
210+
let path = try? AbsolutePath(validating: overrideString) {
211+
return path
211212
} else if let toolDir = toolDirectory,
212213
let path = lookupExecutablePath(filename: executableName(executable), currentWorkingDirectory: nil, searchPaths: [toolDir]) {
213214
// Looking for tools from the tools directory.

0 commit comments

Comments
 (0)