Skip to content

Commit 3b853b3

Browse files
Fix finding of xz in the PATH
- Seems like the environment needed to be passed to the which() method.
1 parent c63f6be commit 3b853b3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Download.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ extension SwiftSDKGenerator {
8686
let xzPath = try await which("xz")
8787
if xzPath == nil {
8888
logger.warning("""
89-
The 'xz' utility was not found in path. \
89+
The `xz` utility was not found in `PATH`. \
9090
Consider installing it for more efficient downloading of package lists.
9191
""")
9292
}

Sources/SwiftSDKGenerator/SystemUtils/which.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import AsyncProcess
14+
import Foundation
1415

1516
/// Look for an executable using the `which` utility.
1617
///
@@ -19,9 +20,12 @@ import AsyncProcess
1920
/// - Returns: The path to the executable if found, otherwise nil.
2021
func which(_ executableName: String) async throws -> String? {
2122
let result = try await ProcessExecutor.runCollectingOutput(
22-
executable: "/usr/bin/which", [executableName], collectStandardOutput: true, collectStandardError: false
23+
executable: "/usr/bin/which", [executableName], collectStandardOutput: true, collectStandardError: false,
24+
environment: ProcessInfo.processInfo.environment
2325
)
2426

27+
try result.exitReason.throwIfNonZero()
28+
2529
if let output = result.standardOutput {
2630
let path = String(buffer: output).trimmingCharacters(in: .whitespacesAndNewlines)
2731
return path.isEmpty ? nil : path

0 commit comments

Comments
 (0)