Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit 6a4a4bd

Browse files
committed
Warn against available rustup but wsl rustup not working on Windows
1 parent a294517 commit 6a4a4bd

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/rustup.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,14 @@ async function hasToolchain(config: RustupConfig): Promise<boolean> {
9090
return stdout.includes(config.channel);
9191
} catch (e) {
9292
console.log(e);
93-
// rustup not present
93+
const rustupFoundButNotInWSLMode =
94+
config.useWSL && (await hasRustup({ useWSL: false, ...config }));
95+
9496
window.showErrorMessage(
95-
'Rustup not available. Install from https://www.rustup.rs/',
97+
rustupFoundButNotInWSLMode
98+
? `Rustup is installed but can't be found under WSL. Ensure that
99+
invoking \`wsl rustup\` works correctly.`
100+
: 'Rustup not available. Install from https://www.rustup.rs/',
96101
);
97102
throw e;
98103
}
@@ -232,6 +237,15 @@ export async function getVersion(config: RustupConfig): Promise<string> {
232237
}
233238
}
234239

240+
/**
241+
* Returns whether Rustup is invokable and available.
242+
*/
243+
export function hasRustup(config: RustupConfig): Promise<boolean> {
244+
return getVersion(config)
245+
.then(() => true)
246+
.catch(() => false);
247+
}
248+
235249
/**
236250
* Returns active (including local overrides) toolchain, as specified by rustup.
237251
* May throw if rustup at specified path can't be executed.

0 commit comments

Comments
 (0)