diff --git a/cabal-testsuite/src/Test/Cabal/Prelude.hs b/cabal-testsuite/src/Test/Cabal/Prelude.hs index e0e63ac18f6..6a9b3b84953 100644 --- a/cabal-testsuite/src/Test/Cabal/Prelude.hs +++ b/cabal-testsuite/src/Test/Cabal/Prelude.hs @@ -1156,5 +1156,7 @@ findDependencyInStore storeDir pkgName = do then filter (not . flip elem "aeiou") pkgName -- simulates the way 'hashedInstalledPackageId' uses to compress package name else pkgName - let libDir = head $ filter (pkgName' `isPrefixOf`) packageDirs + let libDir = case filter (pkgName' `isPrefixOf`) packageDirs of + [] -> error $ "Could not find " <> pkgName' <> " when searching for " <> pkgName' <> " in\n" <> show packageDirs + (dir:_) -> dir pure (storeDir storeDirForGhcVersion libDir)