Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 071619d

Browse files
committed
Fix rustup install notification not showing
Add linux note to maybe use package manager instead of rustup home script install
1 parent 41dc161 commit 071619d

File tree

1 file changed

+44
-34
lines changed

1 file changed

+44
-34
lines changed

lib/index.js

+44-34
Original file line numberDiff line numberDiff line change
@@ -305,43 +305,40 @@ class RustLanguageClient extends AutoLanguageClient {
305305
* @param {string} toolchain
306306
*/
307307
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'])
313315

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
328329
})
330+
})
329331

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+
)
336337
}
337338
}
338-
else {
339-
this._handleMissingToolchainMissingRls(toolchain)
340-
}
341339
}
342-
catch (e) {
343-
logErr(e)
344-
this._handleMissingRustup()
340+
else {
341+
this._handleMissingToolchainMissingRls(toolchain)
345342
}
346343
}
347344

@@ -393,15 +390,28 @@ class RustLanguageClient extends AutoLanguageClient {
393390
/** Takes appropriate action when missing rustup */
394391
async _handleMissingRustup() {
395392
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+
396397
let clicked = await atomPrompt("`rustup` is not available", {
397-
description: "From https://www.rustup.rs/",
398+
description,
398399
detail: "curl https://sh.rustup.rs -sSf | sh"
399400
}, ["Install"])
400401

401402
if (clicked === "Install") {
402403
// 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)
405415
}
406416
}
407417
catch (e) {

0 commit comments

Comments
 (0)