Skip to content

Commit 6f2bbc0

Browse files
committed
Get rid of internal-ghcup
1 parent a76c628 commit 6f2bbc0

File tree

3 files changed

+22
-29
lines changed

3 files changed

+22
-29
lines changed

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,26 @@ The environment _only will be visible for the lsp server_, not for other extensi
7171

7272
### Downloaded binaries
7373

74-
This extension will download `haskell-language-server` binaries either via an internal ghcup (it will download it automaticlaly)
75-
or via a system ghcup (which must be present), unless you set the config option `haskell.manageHLS` to `PATH` (the extension
76-
will ask you on first start).
74+
This extension will download `haskell-language-server` binaries and the rest of the toolchain if you selected to use GHCup during
75+
first start. Check the `haskell.manageHLS` setting.
7776

7877
It will then download the newest version of haskell-language-server which has support for the required ghc.
7978
That means it could use an older version than the latest one, without the last features and bug fixes.
8079
For example, if a project needs ghc-8.10.4 the extension will download and use haskell-language-server-1.4.0, the lastest version which supported ghc-8.10.4. Even if the lastest global haskell language-server version is 1.5.1.
8180

82-
If you have disk space issues and use system ghcup, check `ghcup gc --help`.
83-
If you have disk space issues and use the internal ghcup, check the following directories, depending on your platform
84-
and possible delete them:
81+
If you have disk space issues, check `ghcup gc --help`.
82+
83+
You can also instruct the extension to use a different installation directory for the toolchain,
84+
e.g. to not interfere with system GHCup installation. Depending on your platform, add the full
85+
resolved path like so:
86+
87+
```json
88+
"haskell.serverEnvironment": {
89+
"GHCUP_INSTALL_BASE_PREFIX": "/home/foo/.config/Code/User/globalStorage/haskell.haskell/"
90+
}
91+
```
92+
93+
The internal storage paths for the extension depend on the platform:
8594

8695
| Platform | Path |
8796
| -------- | ------------------------------------------------------------------------------- |

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,10 @@
164164
"description": "How to manage/find HLS installations.",
165165
"enum": [
166166
"system-ghcup",
167-
"internal-ghcup",
168167
"PATH"
169168
],
170169
"enumDescriptions": [
171170
"Will use ghcup and manage Haskell toolchain in the default location (usually '~/.ghcup')",
172-
"Will use ghcup and manage Haskell toolchain in an isolated VSCode specific location (to not interfere with system installations)",
173171
"Discovers HLS executables in system PATH"
174172
]
175173
},

src/hlsBinaries.ts

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface IEnvVars {
2626
[key: string]: string;
2727
}
2828

29-
type ManageHLS = 'system-ghcup' | 'internal-ghcup' | 'PATH';
29+
type ManageHLS = 'system-ghcup' | 'PATH';
3030
let manageHLS = workspace.getConfiguration('haskell').get('manageHLS') as ManageHLS | null;
3131

3232
// On Windows the executable needs to be stored somewhere with an .exe extension
@@ -103,6 +103,9 @@ async function callAsync(
103103
reject: (reason?: any) => void
104104
) => void
105105
): Promise<string> {
106+
let newEnv: IEnvVars = workspace.getConfiguration('haskell').get('serverEnvironment') || {};
107+
newEnv = Object.assign(process.env, newEnv);
108+
newEnv = Object.assign(newEnv, (envAdd || {}));
106109
return window.withProgress(
107110
{
108111
location: ProgressLocation.Notification,
@@ -116,7 +119,6 @@ async function callAsync(
116119
token.onCancellationRequested(() => {
117120
logger.warn(`User canceled the execution of '${command}'`);
118121
});
119-
const newEnv = envAdd ? Object.assign(process.env, envAdd) : process.env;
120122
// Need to set the encoding to 'utf8' in order to get back a string
121123
// We execute the command in a shell for windows, to allow use .cmd or .bat scripts
122124
const childProcess = child_process
@@ -231,11 +233,9 @@ export async function findHaskellLanguageServer(
231233
const decision =
232234
(await window.showInformationMessage(promptMessage, 'automatically via GHCup', 'manually via PATH')) ||
233235
null;
234-
if (decision === 'system ghcup (recommended)') {
236+
if (decision === 'automatically via GHCup') {
235237
manageHLS = 'system-ghcup';
236-
} else if (decision === 'internal ghcup') {
237-
manageHLS = 'internal-ghcup';
238-
} else if (decision === 'PATH') {
238+
} else if (decision === 'manually via PATH') {
239239
manageHLS = 'PATH';
240240
} else {
241241
window.showWarningMessage('Choosing default PATH method for HLS discovery. You can change this via \'haskell.manageHLS\' in the settings.');
@@ -332,7 +332,6 @@ async function callGHCup(
332332
const metadataUrl = workspace.getConfiguration('haskell').metadataURL;
333333

334334
const storagePath: string = await getStoragePath(context);
335-
const ghcup = manageHLS === 'system-ghcup' ? `ghcup${exeExt}` : path.join(storagePath, `ghcup${exeExt}`);
336335
if (manageHLS === 'system-ghcup') {
337336
return await callAsync(
338337
'ghcup',
@@ -344,19 +343,6 @@ async function callGHCup(
344343
undefined,
345344
callback
346345
);
347-
} else if (manageHLS === 'internal-ghcup') {
348-
return await callAsync(
349-
ghcup,
350-
['--no-verbose'].concat(metadataUrl ? ['-s', metadataUrl] : []).concat(args),
351-
storagePath,
352-
logger,
353-
title,
354-
cancellable,
355-
{
356-
GHCUP_INSTALL_BASE_PREFIX: storagePath,
357-
},
358-
callback
359-
);
360346
} else {
361347
throw new Error(`Internal error: tried to call ghcup while haskell.manageHLS is set to ${manageHLS}. Aborting!`);
362348
}
@@ -465,7 +451,7 @@ export async function getGHCup(context: ExtensionContext, logger: Logger): Promi
465451
throw new MissingToolError('ghcup');
466452
}
467453

468-
if (manageHLS === 'system-ghcup' || manageHLS == 'internal-ghcup') {
454+
if (manageHLS === 'system-ghcup') {
469455
logger.info(`found ghcup at ${localGHCup}`);
470456
const args = ['upgrade'];
471457
await callGHCup(context, logger, args, 'Upgrading ghcup', true);

0 commit comments

Comments
 (0)