@@ -82,8 +82,9 @@ function computeDownloadLink(release: string): string {
82
82
export async function cargoInstall (
83
83
packageName : string ,
84
84
locked = false
85
- ) : Promise < boolean > {
85
+ ) : Promise < string | undefined > {
86
86
const command = process . platform === "win32" ? "cargo.exe" : "cargo" ;
87
+
87
88
try {
88
89
// eslint-disable-next-line @typescript-eslint/no-unused-vars
89
90
const { stdout, stderr } = await execAsync (
@@ -93,7 +94,7 @@ export async function cargoInstall(
93
94
}
94
95
) ;
95
96
96
- return true ;
97
+ return ;
97
98
} catch ( error ) {
98
99
const msg = unknownErrorToString ( error ) ;
99
100
if (
@@ -109,7 +110,7 @@ export async function cargoInstall(
109
110
msg
110
111
) ;
111
112
112
- return true ;
113
+ return ;
113
114
}
114
115
Logger . error (
115
116
LoggerSource . rustUtil ,
@@ -118,7 +119,7 @@ export async function cargoInstall(
118
119
) } `
119
120
) ;
120
121
121
- return false ;
122
+ return unknownErrorToString ( error ) ;
122
123
}
123
124
}
124
125
@@ -296,7 +297,7 @@ export async function checkRustInstallation(): Promise<boolean> {
296
297
* @returns {boolean } True if all requirements are met or have been installed, false otherwise.
297
298
*/
298
299
export async function downloadAndInstallRust ( ) : Promise < boolean > {
299
- let result = await checkRustInstallation ( ) ;
300
+ const result = await checkRustInstallation ( ) ;
300
301
if ( ! result ) {
301
302
return false ;
302
303
}
@@ -329,20 +330,41 @@ export async function downloadAndInstallRust(): Promise<boolean> {
329
330
330
331
// install flip-link
331
332
const flipLink = "flip-link" ;
332
- result = await cargoInstall ( flipLink , false ) ;
333
- if ( ! result ) {
334
- void window . showErrorMessage (
335
- `Failed to install cargo package '${ flipLink } '.` +
336
- "Please check the logs."
337
- ) ;
333
+ let cargoInstResult = await cargoInstall ( flipLink , false ) ;
334
+ if ( cargoInstResult !== undefined ) {
335
+ if ( cargoInstResult . includes ( "error: linker `link.exe` not found" ) ) {
336
+ void window
337
+ . showErrorMessage (
338
+ `Failed to install cargo package '${ flipLink } '` +
339
+ " because the MSVC linker is not found" +
340
+ " or Windows SDK components are missing." ,
341
+ "More Info"
342
+ )
343
+ . then ( selection => {
344
+ if ( selection === "More Info" ) {
345
+ env . openExternal (
346
+ Uri . parse (
347
+ // eslint-disable-next-line max-len
348
+ "https://rust-lang.github.io/rustup/installation/windows-msvc.html#manual-install" ,
349
+ true
350
+ )
351
+ ) ;
352
+ }
353
+ } ) ;
354
+ } else {
355
+ void window . showErrorMessage (
356
+ `Failed to install cargo package '${ flipLink } '.` +
357
+ "Please check the logs."
358
+ ) ;
359
+ }
338
360
339
361
return false ;
340
362
}
341
363
342
364
// or install probe-rs-tools
343
365
const probeRsTools = "defmt-print" ;
344
- result = await cargoInstall ( probeRsTools , true ) ;
345
- if ( ! result ) {
366
+ cargoInstResult = await cargoInstall ( probeRsTools , true ) ;
367
+ if ( ! cargoInstResult ) {
346
368
void window . showErrorMessage (
347
369
`Failed to install cargo package '${ probeRsTools } '.` +
348
370
"Please check the logs."
@@ -353,8 +375,8 @@ export async function downloadAndInstallRust(): Promise<boolean> {
353
375
354
376
// install elf2uf2-rs
355
377
const elf2uf2Rs = "elf2uf2-rs" ;
356
- result = await cargoInstall ( elf2uf2Rs , true ) ;
357
- if ( ! result ) {
378
+ cargoInstResult = await cargoInstall ( elf2uf2Rs , true ) ;
379
+ if ( ! cargoInstResult ) {
358
380
void window . showErrorMessage (
359
381
`Failed to install cargo package '${ elf2uf2Rs } '.` +
360
382
"Please check the logs."
0 commit comments