@@ -168,7 +168,6 @@ async function findServerExecutable(context: ExtensionContext, logger: Logger, f
168
168
return exePath ;
169
169
} else {
170
170
const msg = `Could not find a HLS binary at ${ exePath } ! Consider installing HLS via ghcup or change "haskell.manageHLS" in your settings.` ;
171
- window . showErrorMessage ( msg ) ;
172
171
throw new Error ( msg ) ;
173
172
}
174
173
}
@@ -188,7 +187,6 @@ async function findHLSinPATH(context: ExtensionContext, logger: Logger, folder?:
188
187
}
189
188
const msg =
190
189
'Could not find a HLS binary in PATH! Consider installing HLS via ghcup or change "haskell.manageHLS" in your settings.' ;
191
- window . showErrorMessage ( msg ) ;
192
190
throw new Error ( msg ) ;
193
191
}
194
192
@@ -359,7 +357,6 @@ async function getLatestProjectHLS(
359
357
. pop ( ) ;
360
358
361
359
if ( ! latest ) {
362
- window . showErrorMessage ( noMatchingHLS ) ;
363
360
throw new Error ( noMatchingHLS ) ;
364
361
} else {
365
362
return [ latest [ 0 ] , projectGhc ] ;
@@ -433,14 +430,26 @@ export async function upgradeGHCup(context: ExtensionContext, logger: Logger): P
433
430
}
434
431
}
435
432
436
- export async function findGHCup ( context : ExtensionContext , logger : Logger ) : Promise < string > {
433
+ export async function findGHCup ( context : ExtensionContext , logger : Logger , folder ?: WorkspaceFolder ) : Promise < string > {
437
434
logger . info ( 'Checking for ghcup installation' ) ;
438
- const localGHCup = [ 'ghcup' ] . find ( executableExists ) ;
439
- if ( ! localGHCup ) {
440
- throw new MissingToolError ( 'ghcup' ) ;
435
+ let exePath = workspace . getConfiguration ( 'haskell' ) . get ( 'ghcupExecutablePath' ) as string ;
436
+ if ( exePath ) {
437
+ logger . info ( `Trying to find the ghcup executable in: ${ exePath } ` ) ;
438
+ exePath = resolvePathPlaceHolders ( exePath , folder ) ;
439
+ logger . log ( `Location after path variables substitution: ${ exePath } ` ) ;
440
+ if ( await executableExists ( exePath ) ) {
441
+ return exePath ;
442
+ } else {
443
+ throw new Error ( `Could not find a ghcup binary at ${ exePath } !` ) ;
444
+ }
441
445
} else {
442
- logger . info ( `found ghcup at ${ localGHCup } ` ) ;
443
- return localGHCup
446
+ const localGHCup = [ 'ghcup' ] . find ( executableExists ) ;
447
+ if ( ! localGHCup ) {
448
+ throw new MissingToolError ( 'ghcup' ) ;
449
+ } else {
450
+ logger . info ( `found ghcup at ${ localGHCup } ` ) ;
451
+ return localGHCup
452
+ }
444
453
}
445
454
}
446
455
0 commit comments