Fail when Swift installation fails#2080
Conversation
src/commands/installSwiftly.ts
Outdated
|
|
||
| // Install toolchains | ||
| const swiftlyPath = path.join(Swiftly.defaultHomeDir(), "bin/swiftly"); | ||
| let installSuccess = true; |
There was a problem hiding this comment.
we should validate that the versions array is not empty, otherwise installSuccess will report true without installing
There was a problem hiding this comment.
If there is nothing to install, we still want to prompt the user the restart, and return true. Which is what happens currently:
let installSuccess = true;
for (const version of swiftVersions) {
installSuccess =
installSuccess &&
(await installSwiftlyToolchainWithProgress(
version,
extensionRoot,
logger,
swiftlyPath
));
}
// The for loop is skipped, and the user is prompted to restart
if (installSuccess) {
await promptToRestartVSCode();
return true;
} The issue seems to a bad variable name: promptRestart might be better.
There was a problem hiding this comment.
Thinking on the original implementation: I think we should, at the very least, install the latest toolchain if no toolchain versions are provided. That's the whole point of installing swiftly, after all.
Thankfully, swiftly makes this easy by letting us do swiftly install latest. So, we can just add "latest" if the array is empty.
src/commands/installSwiftly.ts
Outdated
| await promptToRestartVSCode(); | ||
| return true; | ||
| } else { | ||
| await vscode.window.showErrorMessage("Installation failed", { |
There was a problem hiding this comment.
Do we get any error message from the installation failure? It would be useful to show the failure message from the install to help the user diagnose why it failed.
Description
Currently, the Swiftly installation flow doesn't know if the Swift install failed — it prompts the user to restart their editor as if nothing happened:
This PR checks if any of the installations failed. If any installation failed, a popup is rendered telling the user to check their Swift version in
.swift-version.Issue: #2070
Tasks
.swift-version, and confirmed that the "restart VS Code" modal was replaced by the "installation failed" modal..swift-version, and made sure the "restart VS Code" model was still rendered.