@@ -87,6 +87,15 @@ async function rustupDefaultToolchain() {
87
87
return stdout . split ( "-" ) [ 0 ] . trim ( )
88
88
}
89
89
90
+ async function hasCommand ( rustCommand ) {
91
+ try {
92
+ await exec ( `${ rustCommand } -V` )
93
+ return true
94
+ } catch ( e ) {
95
+ return false
96
+ }
97
+ }
98
+
90
99
/** @return {?string } developer override of the command to start a Rls instance */
91
100
function rlsCommandOverride ( ) {
92
101
return atom . config . get ( 'ide-rust.rlsCommandOverride' )
@@ -242,6 +251,14 @@ async function checkRls(busySignalService, cwd) {
242
251
const toolchainArg = toolchain && `--toolchain ${ toolchain } ` || ""
243
252
244
253
_checkingRls = ( async ( ) => {
254
+ if ( ! await hasCommand ( "rustup" ) ) {
255
+ if ( await hasCommand ( "rls" ) ) {
256
+ return // have system rls without rustup
257
+ } else {
258
+ throw new Error ( "rls & rustup missing" )
259
+ }
260
+ }
261
+
245
262
let { stdout : toolchainList } = await exec ( `rustup component list ${ toolchainArg } ` , { cwd } )
246
263
if (
247
264
toolchainList . search ( / ^ r l s .* \( ( d e f a u l t | i n s t a l l e d ) \) $ / m) >= 0 &&
@@ -280,14 +297,14 @@ class RustLanguageClient extends AutoLanguageClient {
280
297
this . config = {
281
298
rlsToolchain : {
282
299
description : 'Sets the toolchain installed using rustup and used to run the Rls.' +
283
- ' When blank will use the rustup or system default.' +
300
+ ' When blank will use the rustup/ system default.' +
284
301
' For example ***nightly***, ***stable***, ***beta***, or ***nightly-yyyy-mm-dd***.' ,
285
302
type : 'string' ,
286
303
default : '' ,
287
304
order : 1
288
305
} ,
289
306
checkForToolchainUpdates : {
290
- description : 'Check on startup & periodically for toolchain updates, prompting to install if available' ,
307
+ description : 'Check on startup & periodically for rustup toolchain updates, prompting to install if available. ' ,
291
308
type : 'boolean' ,
292
309
default : true ,
293
310
order : 2
@@ -336,6 +353,12 @@ class RustLanguageClient extends AutoLanguageClient {
336
353
async _promptToUpdateToolchain ( ) {
337
354
if ( ! atom . config . get ( 'ide-rust.checkForToolchainUpdates' ) ) return
338
355
356
+ if ( ! await hasCommand ( "rustup" ) ) {
357
+ atom . config . set ( 'ide-rust.checkForToolchainUpdates' , false )
358
+ this . _handleMissingRustup ( )
359
+ return
360
+ }
361
+
339
362
const confToolchain = configToolchain ( ) || await rustupDefaultToolchain ( )
340
363
if ( ! confToolchain ) return
341
364
@@ -635,7 +658,7 @@ class RustLanguageClient extends AutoLanguageClient {
635
658
return
636
659
}
637
660
638
- if ( ! this . _periodicUpdateChecking ) {
661
+ if ( ! this . _periodicUpdateChecking && await hasCommand ( "rustup" ) ) {
639
662
// if haven't started periodic checks for updates yet start now
640
663
let periodicUpdateTimeoutId
641
664
const periodicUpdate = async ( ) => {
@@ -657,9 +680,7 @@ class RustLanguageClient extends AutoLanguageClient {
657
680
658
681
let cmdOverride = rlsCommandOverride ( )
659
682
if ( cmdOverride ) {
660
- if ( ! this . _warnedAboutRlsCommandOverride && cmdOverride !== 'rls' ) {
661
- // Don't warn if literally 'rls' as this is a workaround for no-rustup environments
662
- // TODO: Remove !== 'rls' check once better no-rustup support is in
683
+ if ( ! this . _warnedAboutRlsCommandOverride ) {
663
684
clearIdeRustInfos ( )
664
685
atom . notifications . addInfo ( `Using rls command \`${ cmdOverride } \`` )
665
686
this . _warnedAboutRlsCommandOverride = true
0 commit comments