diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,5 +1,9 @@
 # Changelog for pantry
 
+## v0.5.5
+
+* Support Cabal 3.6
+
 ## v0.5.4
 
 * Support aeson 2
diff --git a/pantry.cabal b/pantry.cabal
--- a/pantry.cabal
+++ b/pantry.cabal
@@ -5,7 +5,7 @@
 -- see: https://github.com/sol/hpack
 
 name:           pantry
-version:        0.5.4
+version:        0.5.5
 synopsis:       Content addressable Haskell package management
 description:    Please see the README on Github at <https://github.com/commercialhaskell/pantry#readme>
 category:       Development
@@ -53,7 +53,7 @@
       src/
   ghc-options: -Wall
   build-depends:
-      Cabal >=3 && <3.5
+      Cabal >=3 && <3.7
     , aeson
     , ansi-terminal
     , base >=4.10 && <5
@@ -131,7 +131,7 @@
       test
   ghc-options: -Wall
   build-depends:
-      Cabal >=3 && <3.5
+      Cabal >=3 && <3.7
     , QuickCheck
     , aeson
     , ansi-terminal
diff --git a/src/Pantry/Hackage.hs b/src/Pantry/Hackage.hs
--- a/src/Pantry/Hackage.hs
+++ b/src/Pantry/Hackage.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE MultiWayIf #-}
 {-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
@@ -42,7 +43,11 @@
 import qualified Distribution.PackageDescription as Cabal
 import qualified Data.List.NonEmpty as NE
 import Data.Text.Metrics (damerauLevenshtein)
-import System.IO (SeekMode (..)) -- Needed on GHC 8.6
+#if !MIN_VERSION_rio(0,1,16)
+-- Now provided by RIO from the rio package. Resolvers before lts-15.16
+-- (GHC 8.8.3) had rio < 0.1.16.
+import System.IO (SeekMode (..))
+#endif
 import Distribution.PackageDescription (GenericPackageDescription)
 import Distribution.Types.Version (versionNumbers)
 import Distribution.Types.VersionRange (withinRange)
diff --git a/src/Pantry/Types.hs b/src/Pantry/Types.hs
--- a/src/Pantry/Types.hs
+++ b/src/Pantry/Types.hs
@@ -140,7 +140,12 @@
 import Pantry.SHA256 (SHA256)
 import qualified Pantry.SHA256 as SHA256
 import qualified Distribution.Compat.CharParsing as Parse
-import Distribution.CabalSpecVersion (CabalSpecVersion (..), cabalSpecLatest)
+import Distribution.CabalSpecVersion (cabalSpecLatest)
+#if MIN_VERSION_Cabal(3,4,0)
+import Distribution.CabalSpecVersion (cabalSpecToVersionDigits)
+#else
+import Distribution.CabalSpecVersion (CabalSpecVersion (..))
+#endif
 import Distribution.Parsec (PError (..), PWarning (..), showPos, parsec, explicitEitherParsec, ParsecParser)
 import Distribution.Types.PackageName (PackageName, unPackageName, mkPackageName)
 import Distribution.Types.VersionRange (VersionRange)
@@ -555,13 +560,20 @@
   }
     deriving (Show, Generic, Eq, Ord, Typeable)
 
-
 -- | Group input repositories by non-subdir values.
 toAggregateRepos :: [(Repo, RawPackageMetadata)] -> [AggregateRepo]
-toAggregateRepos =
-  fmap (\xs@((repo, _):_) -> AggregateRepo (rToSimpleRepo repo) (fmap (first repoSubdir) xs))
-  . groupBy (\(Repo url1 commit1 type1 _, _) (Repo url2 commit2 type2 _, _) -> (url1, commit1 ,type1) == (url2, commit2, type2))
+toAggregateRepos = mapMaybe toAggregateRepo . groupBy matchRepoExclSubdir
+ where
+  toAggregateRepo :: [(Repo, RawPackageMetadata)] -> Maybe AggregateRepo
+  toAggregateRepo [] = Nothing
+  toAggregateRepo xs@((repo, _):_) =
+    Just $ AggregateRepo (rToSimpleRepo repo) (fmap (first repoSubdir) xs)
 
+  matchRepoExclSubdir x1 x2 =
+    let (Repo url1 commit1 type1 _, _) = x1
+        (Repo url2 commit2 type2 _, _) = x2
+    in  (url1, commit1, type1) == (url2, commit2, type2)
+
 arToSimpleRepo :: AggregateRepo -> SimpleRepo
 arToSimpleRepo AggregateRepo {..} = aRepo
 
@@ -1130,25 +1142,27 @@
 commaSeparated :: NonEmpty Utf8Builder -> Utf8Builder
 commaSeparated = fold . NE.intersperse ", "
 
--- You'd really think there'd be a better way to do this in Cabal.
 cabalSpecLatestVersion :: Version
-cabalSpecLatestVersion =
-  case cabalSpecLatest of
-    CabalSpecV1_0 -> error "this cannot happen"
-    CabalSpecV1_2 -> error "this cannot happen"
-    CabalSpecV1_4 -> error "this cannot happen"
-    CabalSpecV1_6 -> error "this cannot happen"
-    CabalSpecV1_8 -> error "this cannot happen"
-    CabalSpecV1_10 -> error "this cannot happen"
-    CabalSpecV1_12 -> error "this cannot happen"
-    CabalSpecV1_18 -> error "this cannot happen"
-    CabalSpecV1_20 -> error "this cannot happen"
-    CabalSpecV1_22 -> error "this cannot happen"
-    CabalSpecV1_24 -> error "this cannot happen"
-    CabalSpecV2_0 -> error "this cannot happen"
-    CabalSpecV2_2 -> error "this cannot happen"
-    CabalSpecV2_4 -> error "this cannot happen"
-    CabalSpecV3_0 -> mkVersion [3, 0]
+cabalSpecLatestVersion = mkVersion $ cabalSpecToVersionDigits cabalSpecLatest
+
+#if !MIN_VERSION_Cabal(3,4,0)
+cabalSpecToVersionDigits :: CabalSpecVersion -> [Int]
+cabalSpecToVersionDigits CabalSpecV3_0   = [3,0]
+cabalSpecToVersionDigits CabalSpecV2_4   = [2,4]
+cabalSpecToVersionDigits CabalSpecV2_2   = [2,2]
+cabalSpecToVersionDigits CabalSpecV2_0   = [2,0]
+cabalSpecToVersionDigits CabalSpecV1_24  = [1,24]
+cabalSpecToVersionDigits CabalSpecV1_22  = [1,22]
+cabalSpecToVersionDigits CabalSpecV1_20  = [1,20]
+cabalSpecToVersionDigits CabalSpecV1_18  = [1,18]
+cabalSpecToVersionDigits CabalSpecV1_12  = [1,12]
+cabalSpecToVersionDigits CabalSpecV1_10  = [1,10]
+cabalSpecToVersionDigits CabalSpecV1_8   = [1,8]
+cabalSpecToVersionDigits CabalSpecV1_6   = [1,6]
+cabalSpecToVersionDigits CabalSpecV1_4   = [1,4]
+cabalSpecToVersionDigits CabalSpecV1_2   = [1,2]
+cabalSpecToVersionDigits CabalSpecV1_0   = [1,0]
+#endif
 
 data BuildFile = BFCabal !SafeFilePath !TreeEntry
                | BFHpack !TreeEntry -- We don't need SafeFilePath for Hpack since it has to be package.yaml file
