@@ -9,7 +9,7 @@ import { log, isValidExecutable, isRustDocument } from './util';
9
9
import { PersistentState } from './persistent_state' ;
10
10
import { activateTaskProvider } from './tasks' ;
11
11
import { setContextValue } from './util' ;
12
- import { exec , spawnSync } from 'child_process' ;
12
+ import { exec } from 'child_process' ;
13
13
14
14
let ctx : Ctx | undefined ;
15
15
@@ -227,43 +227,30 @@ async function getServer(context: vscode.ExtensionContext, config: Config, state
227
227
} ;
228
228
if ( config . package . releaseTag === null ) return "rust-analyzer" ;
229
229
230
- const platforms : { [ key : string ] : string } = {
231
- "ia32 win32" : "x86_64-pc-windows-msvc" ,
232
- "x64 win32" : "x86_64-pc-windows-msvc" ,
233
- "x64 linux" : "x86_64-unknown-linux-gnu" ,
234
- "x64 darwin" : "x86_64-apple-darwin" ,
235
- "arm64 win32" : "aarch64-pc-windows-msvc" ,
236
- "arm64 linux" : "aarch64-unknown-linux-gnu" ,
237
- "arm64 darwin" : "aarch64-apple-darwin" ,
238
- } ;
239
- let platform = platforms [ `${ process . arch } ${ process . platform } ` ] ;
240
- if ( platform ) {
241
- if ( platform === "x86_64-unknown-linux-gnu" && isMusl ( ) ) {
242
- platform = "x86_64-unknown-linux-musl" ;
243
- }
244
- const ext = platform . indexOf ( "-windows-" ) !== - 1 ? ".exe" : "" ;
245
- const bundled = vscode . Uri . joinPath ( context . extensionUri , "server" , `rust-analyzer${ ext } ` ) ;
246
- const bundledExists = await vscode . workspace . fs . stat ( bundled ) . then ( ( ) => true , ( ) => false ) ;
247
- if ( bundledExists ) {
248
- let server = bundled ;
249
- if ( await isNixOs ( ) ) {
250
- await vscode . workspace . fs . createDirectory ( config . globalStorageUri ) . then ( ) ;
251
- const dest = vscode . Uri . joinPath ( config . globalStorageUri , `rust-analyzer-${ platform } ${ ext } ` ) ;
252
- let exists = await vscode . workspace . fs . stat ( dest ) . then ( ( ) => true , ( ) => false ) ;
253
- if ( exists && config . package . version !== state . serverVersion ) {
254
- await vscode . workspace . fs . delete ( dest ) ;
255
- exists = false ;
256
- }
257
- if ( ! exists ) {
258
- await vscode . workspace . fs . copy ( bundled , dest ) ;
259
- await patchelf ( dest ) ;
260
- server = dest ;
261
- }
230
+ const ext = process . platform === "win32" ? ".exe" : "" ;
231
+ const bundled = vscode . Uri . joinPath ( context . extensionUri , "server" , `rust-analyzer${ ext } ` ) ;
232
+ const bundledExists = await vscode . workspace . fs . stat ( bundled ) . then ( ( ) => true , ( ) => false ) ;
233
+ if ( bundledExists ) {
234
+ let server = bundled ;
235
+ if ( await isNixOs ( ) ) {
236
+ await vscode . workspace . fs . createDirectory ( config . globalStorageUri ) . then ( ) ;
237
+ const dest = vscode . Uri . joinPath ( config . globalStorageUri , `rust-analyzer${ ext } ` ) ;
238
+ let exists = await vscode . workspace . fs . stat ( dest ) . then ( ( ) => true , ( ) => false ) ;
239
+ if ( exists && config . package . version !== state . serverVersion ) {
240
+ await vscode . workspace . fs . delete ( dest ) ;
241
+ exists = false ;
242
+ }
243
+ if ( ! exists ) {
244
+ await vscode . workspace . fs . copy ( bundled , dest ) ;
245
+ await patchelf ( dest ) ;
246
+ server = dest ;
262
247
}
263
- await state . updateServerVersion ( config . package . version ) ;
264
- return server . fsPath ;
265
248
}
249
+ await state . updateServerVersion ( config . package . version ) ;
250
+ return server . fsPath ;
266
251
}
252
+
253
+ await state . updateServerVersion ( undefined ) ;
267
254
await vscode . window . showErrorMessage (
268
255
"Unfortunately we don't ship binaries for your platform yet. " +
269
256
"You need to manually clone rust-analyzer repository and " +
@@ -288,13 +275,6 @@ async function isNixOs(): Promise<boolean> {
288
275
}
289
276
}
290
277
291
- function isMusl ( ) : boolean {
292
- // We can detect Alpine by checking `/etc/os-release` but not Void Linux musl.
293
- // Instead, we run `ldd` since it advertises the libc which it belongs to.
294
- const res = spawnSync ( "ldd" , [ "--version" ] ) ;
295
- return res . stderr != null && res . stderr . indexOf ( "musl libc" ) >= 0 ;
296
- }
297
-
298
278
function warnAboutExtensionConflicts ( ) {
299
279
const conflicting = [
300
280
[ "rust-analyzer" , "matklad.rust-analyzer" ] ,
0 commit comments