Skip to content

Commit f207c2a

Browse files
committed
Pass full path to subcommand executable
This should fix the problem of SwiftPM and other tools not knowing where themselves are.
1 parent e0de0af commit f207c2a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Sources/swift-driver/main.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,17 @@ do {
6666
let subcommandPath = Process.findExecutable(CommandLine.arguments[0])?.parentDirectory.appending(component: subcommand)
6767
?? Process.findExecutable(subcommand)
6868

69-
if subcommandPath == nil || !localFileSystem.exists(subcommandPath!) {
69+
guard let subcommandPath = subcommandPath,
70+
localFileSystem.exists(subcommandPath) else {
7071
fatalError("cannot find subcommand executable '\(subcommand)'")
7172
}
7273

74+
// Pass the full path to subcommand executable.
75+
var arguments = arguments
76+
arguments[0] = subcommandPath.pathString
77+
7378
// Execute the subcommand.
74-
try exec(path: subcommandPath?.pathString ?? "", args: arguments)
79+
try exec(path: subcommandPath.pathString, args: arguments)
7580
}
7681

7782
let executor = try SwiftDriverExecutor(diagnosticsEngine: diagnosticsEngine,

0 commit comments

Comments
 (0)