Skip to content

Commit 1914a94

Browse files
committed
init: Load snapshots on demand during resolver selection
This fixes a regression from 6047a31 that caused _all_ the recommended snapshots to be loaded upfront.
1 parent 2a22d15 commit 1914a94

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/Stack/BuildPlan.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,13 @@ selectBestSnapshot
431431
:: (HasConfig env, HasGHCVariant env)
432432
=> Path Abs Dir -- ^ project root, used for checking out necessary files
433433
-> [GenericPackageDescription]
434-
-> NonEmpty SnapshotDef
434+
-> NonEmpty SnapName
435435
-> RIO env (SnapshotDef, BuildPlanCheck)
436436
selectBestSnapshot root gpds snaps = do
437437
logInfo $ "Selecting the best among "
438438
<> T.pack (show (NonEmpty.length snaps))
439439
<> " snapshots...\n"
440-
F.foldr1 go (NonEmpty.map getResult snaps)
440+
F.foldr1 go (NonEmpty.map (getResult <=< loadResolver . ResolverSnapshot) snaps)
441441
where
442442
go mold mnew = do
443443
old@(_snap, bpc) <- mold

src/Stack/Init.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,7 @@ getDefaultResolver whichCmd stackYaml initOpts mresolver bundle = do
360360
selectSnapResolver = do
361361
let gpds = Map.elems (fmap snd bundle)
362362
snaps <- fmap getRecommendedSnapshots getSnapshots'
363-
sds <- mapM (loadResolver . ResolverSnapshot) snaps
364-
(s, r) <- selectBestSnapshot (parent stackYaml) gpds sds
363+
(s, r) <- selectBestSnapshot (parent stackYaml) gpds snaps
365364
case r of
366365
BuildPlanCheckFail {} | not (omitPackages initOpts)
367366
-> throwM (NoMatchingSnapshot whichCmd snaps)

0 commit comments

Comments
 (0)