Skip to content

Commit f4b1d68

Browse files
committed
Simplify ghcup handling
Avoid using --isolate, since we have our own ghcup prefix anyway.
1 parent ca628e2 commit f4b1d68

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/hlsBinaries.ts

+16-14
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,15 @@ export async function downloadHaskellLanguageServer(context: ExtensionContext, l
147147
const localWrapper = ['haskell-language-server-wrapper'].find(executableExists);
148148
const downloadedWrapper = path.join(
149149
storagePath,
150-
process.platform === 'win32' ? '' : 'bin',
151-
`haskell-language-server-wrapper${exeExt}`
152-
);
153-
const downloadedLegacyWrapper = path.join(
154-
storagePath,
150+
'.ghcup',
151+
'bin',
155152
`haskell-language-server-wrapper${exeExt}`
156153
);
157154
let wrapper: string | undefined;
158-
if (localWrapper) {
155+
if (localWrapper) { // first try PATH
159156
wrapper = localWrapper;
160-
} else if (executableExists(downloadedWrapper)) {
157+
} else if (executableExists(downloadedWrapper)) { // then try internal ghcup
161158
wrapper = downloadedWrapper;
162-
} else if (executableExists(downloadedLegacyWrapper)) {
163-
wrapper = downloadedLegacyWrapper;
164159
}
165160

166161
const ghcup = path.join(storagePath, 'ghcup');
@@ -184,7 +179,7 @@ export async function downloadHaskellLanguageServer(context: ExtensionContext, l
184179
}
185180
await callAsync(
186181
ghcup,
187-
['--no-verbose', 'install', 'hls', '--isolate', storagePath, '--force', 'latest'],
182+
['--no-verbose', 'install', 'hls', '--set', 'latest'],
188183
storagePath,
189184
logger,
190185
`Installing latest HLS`,
@@ -221,12 +216,19 @@ export async function downloadHaskellLanguageServer(context: ExtensionContext, l
221216

222217
// there's a new version
223218
// delete old HLS
224-
await fs.rm(path.join(storagePath, 'bin'), { recursive: true, force: true }, () => {});
225-
await fs.rm(path.join(storagePath, 'lib'), { recursive: true, force: true }, () => {});
219+
await callAsync(
220+
ghcup,
221+
['--no-verbose', 'rm', 'hls', version],
222+
storagePath,
223+
logger,
224+
`Removing old HLS ${version}`,
225+
false,
226+
{ GHCUP_INSTALL_BASE_PREFIX: storagePath }
227+
);
226228
// install new hls
227229
await callAsync(
228230
ghcup,
229-
['--no-verbose', 'install', 'hls', '--isolate', storagePath, '--force', latest_hls_version],
231+
['--no-verbose', 'install', 'hls', '--set', latest_hls_version],
230232
storagePath,
231233
logger,
232234
`Upgrading HLS to ${latest_hls_version}`,
@@ -307,7 +309,7 @@ export async function downloadGHCup(context: ExtensionContext, logger: Logger):
307309
const ghcup = path.join(storagePath, 'ghcup');
308310
// ghcup exists, just upgrade
309311
if (fs.existsSync(path.join(storagePath, 'ghcup'))) {
310-
const args = ['upgrade', '-i'];
312+
const args = ['--no-verbose', 'upgrade', '-i'];
311313
await callAsync(ghcup, args, storagePath, logger, undefined, false, { GHCUP_INSTALL_BASE_PREFIX: storagePath });
312314
} else {
313315
// needs to download ghcup

0 commit comments

Comments
 (0)