Skip to content

Commit 4d9110f

Browse files
committed
Fix package promotion to snapshot
Fixes commercialhaskell/stackage#3185
1 parent 15efd3a commit 4d9110f

7 files changed

Lines changed: 52 additions & 2 deletions

File tree

ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ Bug fixes:
1414
* 1.6.1 introduced a change that made some precompiled cache files use
1515
longer paths, sometimes causing builds to fail on windows. This has been
1616
fixed. See [#3649](https://github.com/commercialhaskell/stack/issues/3649)
17+
* Correct the behavior of promoting a package from snapshot to local
18+
package. This would get triggered when version bounds conflicted in
19+
a snapshot, which could be triggered via Hackage revisions for old
20+
packages. This also should allow custom snapshots to define
21+
conflicting versions of packages without issue. See
22+
[Stackage issue #3185](https://github.com/fpco/stackage/issues/3185).
1723

1824

1925
## v1.6.3

src/Stack/Snapshot.hs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,10 +733,35 @@ splitUnmetDeps extra =
733733

734734
depsMet globals = all (depsMet' globals) . Map.toList . lpiPackageDeps
735735

736-
depsMet' globals (name, intervals) =
736+
-- MSS 2018-01-10. Previously, we would actually perform a version
737+
-- bounds check at this point. I believe this is a mistake: we
738+
-- don't want to promote a package from a snapshot to a local just
739+
-- because the version ranges aren't satisfied. In fact, we
740+
-- intentionally allow snapshots to specify mismatched versions of
741+
-- packages, and try building anyway.
742+
--
743+
-- With the old behavior: a number of packages would be converted
744+
-- and treated as local packages. I specifically stumbled on this
745+
-- while investigating Stackage issues #3185, where a revision to
746+
-- semigroupoids's tagged dependency caused the builds to
747+
-- break. Stack should have just ignored this and printed a
748+
-- warning. Instead, Stack believed that semigroupoids was a local
749+
-- package, not a snapshot package, and failed.
750+
--
751+
-- All that said: I'm pretty certain this is the right behavior,
752+
-- but all of this is strongly indicating that we need some code
753+
-- cleanup around this promotion business. I don't think I did a
754+
-- particularly good job on this code during the extensible
755+
-- snapshot rewrite.
756+
depsMet' globals (name, _intervals) =
737757
case (lpiVersion <$> Map.lookup name globals) <|> Map.lookup name extra of
758+
-- The dependency doesn't exist at all in the snapshot or
759+
-- extra, therefore this package must be promoted to local as
760+
-- well.
738761
Nothing -> False
739-
Just version -> version `withinIntervals` intervals
762+
-- It exists. As explained above, don't bother checking the
763+
-- version bounds, we trust the snapshot.
764+
Just _version -> True
740765

741766
-- | Calculate a 'LoadedPackageInfo' from the given 'GenericPackageDescription'
742767
calculate :: GenericPackageDescription
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import StackTest
2+
3+
main :: IO ()
4+
main = do
5+
stack ["build", "--dry-run"]
6+
stackErr ["build", "--stack-yaml", "with-rev.yaml", "--dry-run"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/unimportant.cabal
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: unimportant
2+
3+
dependencies:
4+
- base
5+
- semigroupoids
6+
- tagged
7+
8+
library: {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
resolver: lts-3.12
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resolver: lts-3.12
2+
extra-deps:
3+
- semigroupoids-5.0.0.4@rev:1

0 commit comments

Comments
 (0)