Skip to content

Commit 51d697f

Browse files
committed
Constants.Config distRelativeDir: use ghc instead of Cabal version
This is a followup fix to the discussion in #5866 about '.stack-work/dist/<platform>/Cabal-*' causing ghc compilation version confusion. With this change the path now becomes '.stack-work/dist/<platform>/ghc-*': ie it disambiguates the path for ghc minor versions, which typically share the same Cabal minor version. Further using a ghc versioned build directories makes it much easier to recognize and clean up old stack build artifacts built with an older ghc (given that ghc minor versions change faster than Cabal).
1 parent f9bde23 commit 51d697f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ Major changes:
1313

1414
Behavior changes:
1515

16+
* The path dist directory path '.stack-work/dist/<platform>/Cabal-*/'
17+
changes to '.stack-work/dist/<platform>/ghc-*/' so that build artifacts are
18+
clearly distinguished by ghc version.
19+
1620
Other enhancements:
1721

1822
* Avoid the duplicate resolving of usage files when parsing `*.hi` files into a

src/Stack/Constants/Config.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ module Stack.Constants.Config
2424
) where
2525

2626
import Path ( (</>), mkRelDir, mkRelFile, parseRelDir )
27-
import Stack.Constants
28-
( cabalPackageName, relDirDist, relDirGhci, relDirHpc )
27+
import Stack.Constants ( relDirDist, relDirGhci, relDirHpc )
2928
import Stack.Prelude
3029
import Stack.Types.BuildConfig ( HasBuildConfig, projectRootL )
31-
import Stack.Types.CompilerPaths ( cabalVersionL )
30+
import Stack.Types.Compiler ( compilerVersionString )
31+
import Stack.Types.CompilerPaths ( compilerVersionL )
3232
import Stack.Types.Config ( Config, HasConfig, stackRootL, workDirL )
3333
import Stack.Types.EnvConfig
3434
( HasEnvConfig, platformGhcRelDir, useShaPathOnWindows )
@@ -162,13 +162,11 @@ templatesDir config = view stackRootL config </> $(mkRelDir "templates")
162162
distRelativeDir :: (MonadThrow m, MonadReader env m, HasEnvConfig env)
163163
=> m (Path Rel Dir)
164164
distRelativeDir = do
165-
cabalPkgVer <- view cabalVersionL
165+
compilerVer <- view compilerVersionL
166166
platform <- platformGhcRelDir
167167
-- Cabal version
168168
envDir <-
169-
parseRelDir $
170-
packageIdentifierString $
171-
PackageIdentifier cabalPackageName cabalPkgVer
169+
parseRelDir $ compilerVersionString compilerVer
172170
platformAndCabal <- useShaPathOnWindows (platform </> envDir)
173171
allDist <- rootDistRelativeDir
174172
pure $ allDist </> platformAndCabal

0 commit comments

Comments
 (0)