Skip to content

Commit f7d0f4b

Browse files
authored
Handle having multiple Swift toolchains on Windows (#795)
It is possible for `which swift` to return multiple lines if the user has more than one Swift toolchain installed. Windows behavior is to use the first one, so we use it as well but also warn the user.
1 parent b65e7d5 commit f7d0f4b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/toolchain/toolchain.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,13 @@ export class SwiftToolchain {
315315
}
316316
case "win32": {
317317
const { stdout } = await execFile("where", ["swift"]);
318-
swift = stdout.trimEnd();
318+
const paths = stdout.trimEnd().split("\r\n");
319+
if (paths.length > 1) {
320+
vscode.window.showWarningMessage(
321+
`Found multiple swift executables in in %PATH%. Using excutable found at ${paths[0]}`
322+
);
323+
}
324+
swift = paths[0];
319325
break;
320326
}
321327
default: {

0 commit comments

Comments
 (0)