Skip to content

Commit 2f419db

Browse files
committed
Make choosing left-biased: local<deps<global
1 parent 5ad68c2 commit 2f419db

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

src/Stack/Build.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,8 +680,8 @@ getPackageDatabases bconfig BTDeps =
680680
liftIO $ liftM return $ runReaderT packageDatabaseDeps bconfig
681681
getPackageDatabases bconfig BTLocals = liftIO $ flip runReaderT bconfig $
682682
sequence
683-
[ packageDatabaseDeps
684-
, packageDatabaseLocal
683+
[ packageDatabaseLocal
684+
, packageDatabaseDeps
685685
]
686686

687687
getInstallRoot :: MonadIO m => BuildConfig -> BuildType -> m (Path Abs Dir)

src/Stack/GhcPkg.hs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ ghcPkg menv pkgDbs args = do
104104

105105
-- | In the given databases, get a single version for all packages, chooses the
106106
-- latest version of each package.
107+
--
108+
-- Package databases passed to these function override eachother in a
109+
-- left-biased way when containing two packages of the same name.
107110
getPackageVersionMapWithGlobalDb
108111
:: (MonadCatch m, MonadIO m, MonadThrow m, MonadLogger m)
109112
=> EnvOverride
@@ -126,20 +129,15 @@ getPackageVersionMapWithGlobalDb menv mmbp pkgDbs = do
126129
Just mbp ->
127130
filtering gdb mbp allGlobals
128131
$logDebug ("Filtered globals: " <> T.pack (show globals))
129-
-- Use unionsWith max to account for cases where the snapshot introduces a
130-
-- newer version of a global package, see:
131-
-- https://github.com/fpco/stack/issues/78
132+
-- M.unions is left-biased.
132133
rest <-
133134
getPackageVersions
134135
menv
135136
pkgDbs
136137
(flip elem pkgDbs)
137-
(M.unionsWith max .
138+
(M.unions .
138139
map (M.fromList . rights))
139-
return
140-
(M.unionsWith
141-
max
142-
[globals, rest])
140+
return (M.unions [rest,globals])
143141
where
144142
filtering gdb mbp allGlobals =
145143
foldM

0 commit comments

Comments
 (0)