From d58a75ef4adab36688878420cc9e2c25bca41ec4 Mon Sep 17 00:00:00 2001
From: Rebecca Turner <rbt@sent.as>
Date: Tue, 27 Aug 2024 13:08:48 -0700
Subject: [PATCH] Don't error if package index is missing (fix #10504)

All of the packages Cabal needs may already be present in the local
package database; we don't know yet!

This is a partial revert of #8944.

See: https://github.com/haskell/cabal/pull/8944#issuecomment-2313147439
---
 cabal-install/src/Distribution/Client/IndexUtils.hs | 4 ++--
 cabal-testsuite/PackageTests/Get/T7248/cabal.out    | 6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/cabal-install/src/Distribution/Client/IndexUtils.hs b/cabal-install/src/Distribution/Client/IndexUtils.hs
index f66cf0d651..705c62d62d 100644
--- a/cabal-install/src/Distribution/Client/IndexUtils.hs
+++ b/cabal-install/src/Distribution/Client/IndexUtils.hs
@@ -457,8 +457,8 @@ readRepoIndex verbosity repoCtxt repo idxState =
       if isDoesNotExistError e
         then do
           case repo of
-            RepoRemote{..} -> dieWithException verbosity $ MissingPackageList repoRemote
-            RepoSecure{..} -> dieWithException verbosity $ MissingPackageList repoRemote
+            RepoRemote{..} -> warn verbosity $ exceptionMessageCabalInstall $ MissingPackageList repoRemote
+            RepoSecure{..} -> warn verbosity $ exceptionMessageCabalInstall $ MissingPackageList repoRemote
             RepoLocalNoIndex local _ ->
               warn verbosity $
                 "Error during construction of local+noindex "
diff --git a/cabal-testsuite/PackageTests/Get/T7248/cabal.out b/cabal-testsuite/PackageTests/Get/T7248/cabal.out
index a172b425d4..0c6e3ce035 100644
--- a/cabal-testsuite/PackageTests/Get/T7248/cabal.out
+++ b/cabal-testsuite/PackageTests/Get/T7248/cabal.out
@@ -1,4 +1,6 @@
 # cabal get
 Warning: <ROOT>/cabal.config: Unrecognized stanza on line 3
-Error: [Cabal-7160]
-The package list for 'repo.invalid' does not exist. Run 'cabal update' to download it.
+Warning: The package list for 'repo.invalid' does not exist. Run 'cabal update' to download it.
+Error: [Cabal-7100]
+There is no package named 'a-b-s-e-n-t'. 
+You may need to run 'cabal update' to get the latest list of available packages.
-- 
GitLab