@@ -82,8 +82,9 @@ function computeDownloadLink(release: string): string {
8282export async function cargoInstall (
8383 packageName : string ,
8484 locked = false
85- ) : Promise < boolean > {
85+ ) : Promise < string | undefined > {
8686 const command = process . platform === "win32" ? "cargo.exe" : "cargo" ;
87+
8788 try {
8889 // eslint-disable-next-line @typescript-eslint/no-unused-vars
8990 const { stdout, stderr } = await execAsync (
@@ -93,7 +94,7 @@ export async function cargoInstall(
9394 }
9495 ) ;
9596
96- return true ;
97+ return ;
9798 } catch ( error ) {
9899 const msg = unknownErrorToString ( error ) ;
99100 if (
@@ -109,7 +110,7 @@ export async function cargoInstall(
109110 msg
110111 ) ;
111112
112- return true ;
113+ return ;
113114 }
114115 Logger . error (
115116 LoggerSource . rustUtil ,
@@ -118,7 +119,7 @@ export async function cargoInstall(
118119 ) } `
119120 ) ;
120121
121- return false ;
122+ return unknownErrorToString ( error ) ;
122123 }
123124}
124125
@@ -296,7 +297,7 @@ export async function checkRustInstallation(): Promise<boolean> {
296297 * @returns {boolean } True if all requirements are met or have been installed, false otherwise.
297298 */
298299export async function downloadAndInstallRust ( ) : Promise < boolean > {
299- let result = await checkRustInstallation ( ) ;
300+ const result = await checkRustInstallation ( ) ;
300301 if ( ! result ) {
301302 return false ;
302303 }
@@ -329,20 +330,41 @@ export async function downloadAndInstallRust(): Promise<boolean> {
329330
330331 // install flip-link
331332 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+ }
338360
339361 return false ;
340362 }
341363
342364 // or install probe-rs-tools
343365 const probeRsTools = "defmt-print" ;
344- result = await cargoInstall ( probeRsTools , true ) ;
345- if ( ! result ) {
366+ cargoInstResult = await cargoInstall ( probeRsTools , true ) ;
367+ if ( ! cargoInstResult ) {
346368 void window . showErrorMessage (
347369 `Failed to install cargo package '${ probeRsTools } '.` +
348370 "Please check the logs."
@@ -353,8 +375,8 @@ export async function downloadAndInstallRust(): Promise<boolean> {
353375
354376 // install elf2uf2-rs
355377 const elf2uf2Rs = "elf2uf2-rs" ;
356- result = await cargoInstall ( elf2uf2Rs , true ) ;
357- if ( ! result ) {
378+ cargoInstResult = await cargoInstall ( elf2uf2Rs , true ) ;
379+ if ( ! cargoInstResult ) {
358380 void window . showErrorMessage (
359381 `Failed to install cargo package '${ elf2uf2Rs } '.` +
360382 "Please check the logs."
0 commit comments