Skip to content

Commit 8d8d6d6

Browse files
committed
Error whether or not project has packages
Guard against triggering an assertion if targets are null
1 parent 8276938 commit 8d8d6d6

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

cabal-install/src/Distribution/Client/CmdRepl.hs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ replAction flags@NixStyleFlags{extraFlags = replFlags@ReplFlags{..}, configFlags
292292

293293
baseCtx <- case targetCtx of
294294
ProjectContext -> do
295-
let pkgs = projectPackages $ projectConfig ctx
296-
when (null targetSelectors && not (null pkgs)) $ do
295+
when (null targetSelectors) $ do
297296
let projectFile = projectConfigProjectFile . projectConfigShared $ projectConfig ctx
297+
let pkgs = projectPackages $ projectConfig ctx
298298
dieWithException verbosity $
299299
RenderReplTargetProblem [render (reportProjectNoTarget projectFile pkgs)]
300300
return ctx
@@ -396,10 +396,15 @@ replAction flags@NixStyleFlags{extraFlags = replFlags@ReplFlags{..}, configFlags
396396

397397
let
398398
elaboratedPlan' =
399-
pruneInstallPlanToTargets
400-
TargetActionRepl
401-
targets
402-
elaboratedPlan
399+
-- Guard against pruning with empty targets and failing an assertion
400+
-- within pruneInstallPlanToTargets.
401+
if null targets
402+
then elaboratedPlan
403+
else
404+
pruneInstallPlanToTargets
405+
TargetActionRepl
406+
targets
407+
elaboratedPlan
403408
includeTransitive = fromFlagOrDefault True (envIncludeTransitive replEnvFlags)
404409

405410
pkgsBuildStatus <-

0 commit comments

Comments
 (0)