diff --git a/cabal-install/src/Distribution/Client/IndexUtils.hs b/cabal-install/src/Distribution/Client/IndexUtils.hs index c01108c2b6e..e6e34530eb6 100644 --- a/cabal-install/src/Distribution/Client/IndexUtils.hs +++ b/cabal-install/src/Distribution/Client/IndexUtils.hs @@ -1177,7 +1177,9 @@ readNoIndexCache verbosity index = do Left msg -> do warn verbosity $ concat - [ "Parsing the index cache failed (" + [ "Parsing the index cache for repo \"" + , unRepoName (repoName repo) + , "\" failed (" , msg , "). " , "Trying to regenerate the index cache..." @@ -1189,6 +1191,8 @@ readNoIndexCache verbosity index = do -- we don't hash cons local repository cache, they are hopefully small Right res -> return res + where + RepoIndex _ctxt repo = index -- | Read the 'Index' cache from the filesystem. Throws IO exceptions -- if any arise and returns Left on invalid input. @@ -1200,7 +1204,11 @@ readIndexCache' index Right . read00IndexCache <$> BSS.readFile (cacheFile index) readNoIndexCache' :: Index -> IO (Either String NoIndexCache) -readNoIndexCache' index = structuredDecodeFileOrFail (cacheFile index) +readNoIndexCache' index = do + exists <- doesFileExist (cacheFile index) + if exists + then structuredDecodeFileOrFail (cacheFile index) + else pure $ Left "No index cache exists yet" -- | Write the 'Index' cache to the filesystem writeIndexCache :: Index -> Cache -> IO () diff --git a/changelog.d/pr-10730 b/changelog.d/pr-10730 new file mode 100644 index 00000000000..e313e8f2283 --- /dev/null +++ b/changelog.d/pr-10730 @@ -0,0 +1,11 @@ +synopsis: Create `noindex.cache` file if missing +packages: cabal-install +prs: #10730 +issues: #9891 +significance: + +description: { + +- Local+noindex repositories will have their `noindex.cache` file created the first time they are accessed. + +}