Skip to content

Commit 6f89d35

Browse files
authored
fix: don't resolve deps as part of lake exe cache query step (#748)
1 parent df5cd40 commit 6f89d35

File tree

4 files changed

+45
-25
lines changed

4 files changed

+45
-25
lines changed

vscode-lean4/src/leanclient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ export class LeanClient implements Disposable {
456456

457457
const progressOptions: ProgressOptions = {
458458
location: ProgressLocation.Notification,
459-
title: '[Server Startup] Starting Lean language server and cloning missing packages [(Click for details)](command:lean4.troubleshooting.showOutput)',
459+
title: '[Server Startup] Starting Lean language server and cloning missing project dependencies [(Click for details)](command:lean4.troubleshooting.showOutput)',
460460
cancellable: false,
461461
}
462462
await window.withProgress(

vscode-lean4/src/projectinit.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,23 @@ Open this project instead?`
414414
return
415415
}
416416

417-
const fetchResult: 'Success' | 'Failure' = await lake({
417+
const lakeRunner = lake({
418418
channel: this.channel,
419419
cwdUri: projectFolder,
420420
context: downloadProjectContext,
421421
toolchainUpdateMode: 'UpdateAutomatically',
422-
}).tryFetchMathlibCacheWithError()
422+
})
423+
424+
const resolveResult: LakeRunnerResult = await lakeRunner.resolveDeps()
425+
if (resolveResult.kind === 'Cancelled') {
426+
return
427+
}
428+
if (resolveResult.kind !== 'Success') {
429+
displayLakeRunnerError(resolveResult, 'Cannot clone missing project dependencies.')
430+
return
431+
}
432+
433+
const fetchResult: 'Success' | 'Failure' = await lakeRunner.tryFetchMathlibCacheWithError()
423434
if (fetchResult !== 'Success') {
424435
return
425436
}

vscode-lean4/src/projectoperations.ts

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { commands, Disposable, OutputChannel, QuickPickItem, window } from 'vsco
44
import { LeanClient } from './leanclient'
55
import { LeanClientProvider } from './utils/clientProvider'
66
import {
7-
CacheGetAvailabilityResult,
87
displayLakeRunnerError,
98
FetchMathlibCacheResult,
109
lake,
@@ -39,6 +38,15 @@ export class ProjectOperationProvider implements Disposable {
3938

4039
private async buildProject() {
4140
await this.runOperation('Build Project', async lakeRunner => {
41+
const resolveResult: LakeRunnerResult = await lakeRunner.resolveDeps()
42+
if (resolveResult.kind === 'Cancelled') {
43+
return
44+
}
45+
if (resolveResult.kind !== 'Success') {
46+
displayLakeRunnerError(resolveResult, 'Cannot clone missing project dependencies.')
47+
return
48+
}
49+
4250
const fetchResult: 'Success' | 'Failure' = await lakeRunner.tryFetchMathlibCacheWithError()
4351
if (fetchResult !== 'Success') {
4452
return
@@ -79,36 +87,33 @@ export class ProjectOperationProvider implements Disposable {
7987
return
8088
}
8189

82-
const checkResult: CacheGetAvailabilityResult = await lakeRunner.isMathlibCacheGetAvailable()
83-
if (checkResult.kind === 'Cancelled') {
84-
return
85-
}
86-
if (checkResult.kind === 'CacheUnavailable') {
87-
displayNotification('Information', 'Project cleaned successfully.')
88-
return
89-
}
90-
if (checkResult.kind !== 'CacheAvailable') {
91-
displayLakeRunnerError(checkResult, 'Cannot check availability of Mathlib cache.')
92-
return
93-
}
94-
95-
const fetchMessage = "Project cleaned successfully. Do you wish to fetch Mathlib's build artifact cache?"
96-
const fetchInput = 'Fetch Cache'
97-
const fetchChoice: string | undefined = await displayNotificationWithInput(
90+
const rebuildMessage = 'Project cleaned successfully. Do you wish to rebuild the project?'
91+
const rebuildInput = 'Rebuild Project'
92+
const rebuildChoice: string | undefined = await displayNotificationWithInput(
9893
'Information',
99-
fetchMessage,
100-
[fetchInput],
101-
'Do Not Fetch Cache',
94+
rebuildMessage,
95+
[rebuildInput],
96+
'Do Not Rebuild',
10297
)
103-
if (fetchChoice !== fetchInput) {
98+
if (rebuildChoice !== rebuildInput) {
10499
return
105100
}
106101

107102
const fetchResult: 'Success' | 'Failure' = await lakeRunner.tryFetchMathlibCacheWithError()
108103
if (fetchResult !== 'Success') {
109104
return
110105
}
111-
displayNotification('Information', 'Mathlib build artifact cache fetched successfully.')
106+
107+
const buildResult: LakeRunnerResult = await lakeRunner.build()
108+
if (buildResult.kind === 'Cancelled') {
109+
return
110+
}
111+
if (buildResult.kind !== 'Success') {
112+
displayLakeRunnerError(buildResult, 'Cannot build project.')
113+
return
114+
}
115+
116+
displayNotification('Information', 'Project rebuilt successfully.')
112117
})
113118
}
114119

vscode-lean4/src/utils/lake.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ export class LakeRunner {
143143
)
144144
}
145145

146+
async resolveDeps(): Promise<LakeRunnerResult> {
147+
return this.runLakeCommandWithProgress('resolve-deps', [], 'Cloning missing project dependencies')
148+
}
149+
146150
async isMathlibCacheGetAvailable(): Promise<CacheGetAvailabilityResult> {
147151
const result: LakeRunnerResult = await this.runLakeCommandWithProgress(
148152
'exe',

0 commit comments

Comments
 (0)