@@ -12,7 +12,7 @@ import { PersistentState } from './persistent_state';
12
12
import { fetchRelease , download } from './net' ;
13
13
import { activateTaskProvider } from './tasks' ;
14
14
import { setContextValue } from './util' ;
15
- import { exec } from 'child_process' ;
15
+ import { exec , spawnSync } from 'child_process' ;
16
16
17
17
let ctx : Ctx | undefined ;
18
18
@@ -297,7 +297,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string
297
297
"arm64 linux" : "aarch64-unknown-linux-gnu" ,
298
298
"arm64 darwin" : "aarch64-apple-darwin" ,
299
299
} ;
300
- const platform = platforms [ `${ process . arch } ${ process . platform } ` ] ;
300
+ let platform = platforms [ `${ process . arch } ${ process . platform } ` ] ;
301
301
if ( platform === undefined ) {
302
302
await vscode . window . showErrorMessage (
303
303
"Unfortunately we don't ship binaries for your platform yet. " +
@@ -309,6 +309,9 @@ async function getServer(config: Config, state: PersistentState): Promise<string
309
309
) ;
310
310
return undefined ;
311
311
}
312
+ if ( platform === "x86_64-unknown-linux-gnu" && isMusl ( ) ) {
313
+ platform = "x86_64-unknown-linux-musl" ;
314
+ }
312
315
const ext = platform . indexOf ( "-windows-" ) !== - 1 ? ".exe" : "" ;
313
316
const dest = path . join ( config . globalStoragePath , `rust-analyzer-${ platform } ${ ext } ` ) ;
314
317
const exists = await fs . stat ( dest ) . then ( ( ) => true , ( ) => false ) ;
@@ -365,6 +368,13 @@ async function isNixOs(): Promise<boolean> {
365
368
}
366
369
}
367
370
371
+ function isMusl ( ) : boolean {
372
+ // We can detect Alpine by checking `/etc/os-release` but not Void Linux musl.
373
+ // Instead, we run `ldd` since it advertises the libc which it belongs to.
374
+ const res = spawnSync ( "ldd" , [ "--version" ] ) ;
375
+ return res . stderr != null && res . stderr . indexOf ( "musl libc" ) >= 0 ;
376
+ }
377
+
368
378
async function downloadWithRetryDialog < T > ( state : PersistentState , downloadFunc : ( ) => Promise < T > ) : Promise < T > {
369
379
while ( true ) {
370
380
try {
0 commit comments