11import * as vscode from 'vscode' ;
22import * as parser from './trace' ;
3+ import * as path from 'path' ;
34
45import os = require( 'node:os' ) ;
56import cp = require( 'child_process' ) ;
@@ -220,6 +221,21 @@ export class TraceProvider implements vscode.WebviewViewProvider {
220221 } ) ;
221222 }
222223
224+ private findFileOnPath ( name : string ) {
225+ if ( name . startsWith ( '/' ) ) { return true } ;
226+
227+ const paths = ( process . env . PATH || '' )
228+ . split ( path . delimiter )
229+ . map ( x => path . resolve ( x , name ) ) ;
230+
231+ for ( const p of paths ) {
232+ if ( fs . existsSync ( p ) ) {
233+ return true ;
234+ }
235+ }
236+ return false ;
237+ }
238+
223239 private exec ( command : string ) {
224240
225241 let result = cp . execSync ( command ) . toString ( ) ;
@@ -251,7 +267,7 @@ export class TraceProvider implements vscode.WebviewViewProvider {
251267
252268 this . _elpi_trace_elaborator = configuration . elpi_trace_elaborator . path ;
253269
254- if ( ! fs . existsSync ( this . _elpi_trace_elaborator . replace ( '$HOME' , os . homedir ( ) ) ) ) {
270+ if ( ! this . findFileOnPath ( this . _elpi_trace_elaborator ) ) {
255271 vscode . window
256272 . showInformationMessage ( `Failed to find elpi trace elaborator` , 'Go to settings' )
257273 . then ( action => {
@@ -322,7 +338,7 @@ export class TraceProvider implements vscode.WebviewViewProvider {
322338 this . _elpi = configuration . elpi . path ;
323339 this . _elpi_trace_elaborator = configuration . elpi_trace_elaborator . path ;
324340
325- if ( ! fs . existsSync ( this . _elpi . replace ( '$HOME' , os . homedir ( ) ) ) ) {
341+ if ( ! this . findFileOnPath ( this . _elpi ) ) {
326342 vscode . window
327343 . showInformationMessage ( `Failed to find elpi` , 'Go to settings' )
328344 . then ( action => {
@@ -332,7 +348,7 @@ export class TraceProvider implements vscode.WebviewViewProvider {
332348 return ;
333349 }
334350
335- if ( ! fs . existsSync ( this . _elpi_trace_elaborator . replace ( '$HOME' , os . homedir ( ) ) ) ) {
351+ if ( ! this . findFileOnPath ( this . _elpi_trace_elaborator ) ) {
336352 vscode . window
337353 . showInformationMessage ( `Failed to find elpi trace elaborator` , 'Go to settings' )
338354 . then ( action => {
@@ -394,7 +410,7 @@ export class TraceProvider implements vscode.WebviewViewProvider {
394410 this . _elpi = configuration . elpi . path ;
395411 this . _elpi_trace_elaborator = configuration . elpi_trace_elaborator . path ;
396412
397- if ( ! fs . existsSync ( this . _elpi . replace ( '$HOME' , os . homedir ( ) ) ) ) {
413+ if ( ! this . findFileOnPath ( this . _elpi ) ) {
398414 vscode . window
399415 . showInformationMessage ( `Failed to find elpi` , 'Go to settings' )
400416 . then ( action => {
@@ -404,7 +420,7 @@ export class TraceProvider implements vscode.WebviewViewProvider {
404420 return ;
405421 }
406422
407- if ( ! fs . existsSync ( this . _elpi_trace_elaborator . replace ( '$HOME' , os . homedir ( ) ) ) ) {
423+ if ( ! this . findFileOnPath ( this . _elpi_trace_elaborator ) ) {
408424 vscode . window
409425 . showInformationMessage ( `Failed to find elpi trace elaborator` , 'Go to settings' )
410426 . then ( action => {
0 commit comments