11import { execSync } from "node:child_process" ;
22import * as vscode from "vscode" ;
3+ import { buildCommand } from "./executable" ;
34
45function testElixirCommand ( command : string ) : false | Buffer {
56 try {
@@ -9,24 +10,27 @@ function testElixirCommand(command: string): false | Buffer {
910 }
1011}
1112
12- export function testElixir ( ) : boolean {
13- const testResult = testElixirCommand ( "elixir" ) ;
13+ export function testElixir ( context : vscode . ExtensionContext ) : boolean {
14+ // Use the same script infrastructure as the language server to ensure
15+ // consistent environment setup (version managers, etc.)
16+ const checkCommand = buildCommand ( context , "elixir_check" , undefined ) ;
17+ const testResult = testElixirCommand ( `"${ checkCommand } "` ) ;
1418
1519 if ( ! testResult ) {
1620 vscode . window . showErrorMessage (
17- "Failed to run ' elixir' command. ElixirLS will probably fail to launch. Logged PATH to Development Console." ,
21+ "Failed to run elixir check command. ElixirLS will probably fail to launch. Logged PATH to Development Console." ,
1822 ) ;
1923 console . warn (
20- `Failed to run ' elixir' command. Current process's PATH: ${ process . env . PATH } ` ,
24+ `Failed to run elixir check command. Current process's PATH: ${ process . env . PATH } ` ,
2125 ) ;
2226 return false ;
2327 }
2428 if ( testResult . length > 0 ) {
2529 vscode . window . showErrorMessage (
26- "Running ' elixir' command caused extraneous print to stdout. See VS Code's developer console for details." ,
30+ "Running elixir check command caused extraneous print to stdout. See VS Code's developer console for details." ,
2731 ) ;
2832 console . warn (
29- `Running ' elixir -e \"\"' printed to stdout:\n${ testResult . toString ( ) } ` ,
33+ `Running elixir check command printed to stdout:\n${ testResult . toString ( ) } ` ,
3034 ) ;
3135 return false ;
3236 }
0 commit comments