From 1ce06745a66f122493cdadbd88a7cf3b7d4a0a9b Mon Sep 17 00:00:00 2001 From: Mike Pilgrem Date: Fri, 6 Mar 2026 22:50:36 +0000 Subject: [PATCH] Fix #6858 Don't prune when all dependencies pruned --- ChangeLog.md | 3 +++ doc/commands/dot_command.md | 3 +-- doc/commands/ls_command.md | 3 +-- src/Stack/DependencyGraph.hs | 4 +--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 4ba4b18917..034489bd67 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -26,6 +26,9 @@ Other enhancements: Bug fixes: +* Stack's `dot` and `ls dependencies` commands no longer prune a package with + dependencies only because all its direct dependencies are to be pruned. + ## v3.9.3 - 2026-02-19 Release notes: diff --git a/doc/commands/dot_command.md b/doc/commands/dot_command.md index cc9e99fe18..9edddb781a 100644 --- a/doc/commands/dot_command.md +++ b/doc/commands/dot_command.md @@ -31,8 +31,7 @@ By default: project packages). Pass the `--reach ` option to exclude packages (including project packages) that cannot reach any of the specified packages in the dependency graph. In both cases, `` is a list of package - names separated by commas. A package with dependencies is pruned if all of - its direct dependencies are pruned; + names separated by commas; * for all relevant project packages, relevant dependencies are included in the output. However, each project package for which dependencies are included can be specified as a target argument. The argument uses the same format as diff --git a/doc/commands/ls_command.md b/doc/commands/ls_command.md index 42a2632350..9485b849d1 100644 --- a/doc/commands/ls_command.md +++ b/doc/commands/ls_command.md @@ -72,8 +72,7 @@ By default: project packages). Pass the `--reach ` option to exclude packages (including project packages) that cannot reach any of the specified packages in the dependency graph. In both cases, `` is a list of package - names separated by commas. A package with dependencies is pruned if all of - its direct dependencies are pruned; + names separated by commas; * for all relevant project packages, relevant dependencies are included in the output. However, each project package for which dependencies are included can be specified as a target argument. The argument uses the same format as diff --git a/src/Stack/DependencyGraph.hs b/src/Stack/DependencyGraph.hs index 2ad8e4db4f..b5a484d572 100644 --- a/src/Stack/DependencyGraph.hs +++ b/src/Stack/DependencyGraph.hs @@ -397,9 +397,7 @@ pruneGraph dontPrune names = if pkg `F.elem` names then Nothing else let filtered = Set.filter (`F.notElem` names) pkgDeps - in if Set.null filtered && not (Set.null pkgDeps) - then Nothing - else Just (filtered, x)) + in Just (filtered, x)) -- | Make sure that all unreachable nodes (orphans) are pruned pruneUnreachable ::