@@ -90,9 +90,14 @@ async function hasToolchain(config: RustupConfig): Promise<boolean> {
90
90
return stdout . includes ( config . channel ) ;
91
91
} catch ( e ) {
92
92
console . log ( e ) ;
93
- // rustup not present
93
+ const rustupFoundButNotInWSLMode =
94
+ config . useWSL && ( await hasRustup ( { useWSL : false , ...config } ) ) ;
95
+
94
96
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/' ,
96
101
) ;
97
102
throw e ;
98
103
}
@@ -144,6 +149,7 @@ async function hasRlsComponents(config: RustupConfig): Promise<boolean> {
144
149
} catch ( e ) {
145
150
console . log ( e ) ;
146
151
window . showErrorMessage ( `Can't detect RLS components: ${ e . message } ` ) ;
152
+ stopSpinner ( "Can't detect RLS components" ) ;
147
153
throw e ;
148
154
}
149
155
}
@@ -218,14 +224,11 @@ export function parseActiveToolchain(rustupOutput: string): string {
218
224
throw new Error ( `couldn't find active toolchains` ) ;
219
225
}
220
226
221
- export async function getVersion (
222
- cwd : string ,
223
- config : RustupConfig ,
224
- ) : Promise < string > {
227
+ export async function getVersion ( config : RustupConfig ) : Promise < string > {
225
228
const versionRegex = / r u s t u p ( [ 0 - 9 ] + \. [ 0 - 9 ] + \. [ 0 - 9 ] + ) / ;
226
229
const execFile = withWsl ( config . useWSL ) . execFile ;
227
230
228
- const output = await execFile ( config . path , [ '--version' ] , { cwd } ) ;
231
+ const output = await execFile ( config . path , [ '--version' ] ) ;
229
232
const versionMatch = output . stdout . toString ( ) . match ( versionRegex ) ;
230
233
if ( versionMatch && versionMatch . length >= 2 ) {
231
234
return versionMatch [ 1 ] ;
@@ -234,6 +237,15 @@ export async function getVersion(
234
237
}
235
238
}
236
239
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
+
237
249
/**
238
250
* Returns active (including local overrides) toolchain, as specified by rustup.
239
251
* May throw if rustup at specified path can't be executed.
0 commit comments