@@ -305,43 +305,40 @@ class RustLanguageClient extends AutoLanguageClient {
305
305
* @param {string } toolchain
306
306
*/
307
307
async _handleMissingToolchain ( toolchain ) {
308
- try {
309
- if ( await checkHasRls ( toolchain ) ) {
310
- let clicked = await atomPrompt ( `\`rustup\` missing ${ toolchain } toolchain` , {
311
- detail : `rustup toolchain install ${ toolchain } ` ,
312
- } , [ 'Install' ] )
308
+ if ( ! await exec ( 'rustup --version' ) . catch ( ( ) => false ) ) {
309
+ this . _handleMissingRustup ( )
310
+ }
311
+ else if ( await checkHasRls ( toolchain ) ) {
312
+ let clicked = await atomPrompt ( `\`rustup\` missing ${ toolchain } toolchain` , {
313
+ detail : `rustup toolchain install ${ toolchain } ` ,
314
+ } , [ 'Install' ] )
313
315
314
- if ( clicked === 'Install' ) {
315
- clearIdeRustInfos ( )
316
- const installPromise = installCompiler ( )
317
- . then ( ( ) => this . _checkToolchain ( ) )
318
- . then ( ( ) => this . _restartLanguageServers ( `Installed Rls toolchain` ) )
319
- . catch ( e => {
320
- console . warn ( e )
321
- clearIdeRustInfos ( )
322
- let err = ( e + '' ) . split ( '\n' )
323
- err = err . length && err [ 0 ] || `Error installing rust \`${ toolchain } \``
324
- atom . notifications . addError ( err , {
325
- detail : 'Check the toolchain is valid & connection is available' ,
326
- dismissable : true
327
- } )
316
+ if ( clicked === 'Install' ) {
317
+ clearIdeRustInfos ( )
318
+ const installPromise = installCompiler ( )
319
+ . then ( ( ) => this . _checkToolchain ( ) )
320
+ . then ( ( ) => this . _restartLanguageServers ( `Installed Rls toolchain` ) )
321
+ . catch ( e => {
322
+ console . warn ( e )
323
+ clearIdeRustInfos ( )
324
+ let err = ( e + '' ) . split ( '\n' )
325
+ err = err . length && err [ 0 ] || `Error installing rust \`${ toolchain } \``
326
+ atom . notifications . addError ( err , {
327
+ detail : 'Check the toolchain is valid & connection is available' ,
328
+ dismissable : true
328
329
} )
330
+ } )
329
331
330
- if ( this . busySignalService ) {
331
- this . busySignalService . reportBusyWhile (
332
- `Installing rust \`${ toolchain } \`` ,
333
- ( ) => installPromise
334
- )
335
- }
332
+ if ( this . busySignalService ) {
333
+ this . busySignalService . reportBusyWhile (
334
+ `Installing rust \`${ toolchain } \`` ,
335
+ ( ) => installPromise
336
+ )
336
337
}
337
338
}
338
- else {
339
- this . _handleMissingToolchainMissingRls ( toolchain )
340
- }
341
339
}
342
- catch ( e ) {
343
- logErr ( e )
344
- this . _handleMissingRustup ( )
340
+ else {
341
+ this . _handleMissingToolchainMissingRls ( toolchain )
345
342
}
346
343
}
347
344
@@ -393,15 +390,28 @@ class RustLanguageClient extends AutoLanguageClient {
393
390
/** Takes appropriate action when missing rustup */
394
391
async _handleMissingRustup ( ) {
395
392
try {
393
+ let description = "Installs from https://www.rustup.rs"
394
+ if ( process . platform === 'linux' )
395
+ description += ", alternatively install rustup with _`apt install rustup`_ or similar and restart."
396
+
396
397
let clicked = await atomPrompt ( "`rustup` is not available" , {
397
- description : "From https://www.rustup.rs/" ,
398
+ description,
398
399
detail : "curl https://sh.rustup.rs -sSf | sh"
399
400
} , [ "Install" ] )
400
401
401
402
if ( clicked === "Install" ) {
402
403
// Install rustup and try again
403
- await installRustup ( )
404
- this . _checkToolchain ( ) . catch ( logErr )
404
+ let installRustupPromise = installRustup ( )
405
+ if ( this . busySignalService ) {
406
+ this . busySignalService . reportBusyWhile (
407
+ `Installing rustup` ,
408
+ ( ) => installRustupPromise
409
+ )
410
+ }
411
+ await installRustupPromise
412
+ await this . _checkToolchain ( )
413
+ . then ( ( ) => this . _restartLanguageServers ( ) )
414
+ . catch ( logErr )
405
415
}
406
416
}
407
417
catch ( e ) {
0 commit comments