- 
                Notifications
    
You must be signed in to change notification settings  - Fork 723
 
Description
New summary by @ezyang. When you run cabal install and it has been a while since you have run cabal update, you get this useful message:
Warning: The package list for 'next-hackage' is 16 days old.
Run 'cabal update' to get the latest list of available packages.
This message is computed by looking at the most recently updated package in the package index, and then emitting a message if it was from too long ago. Unfortunately, there is a bug in how we perform this check.
Steps to reproduce.
- Configure the 
next-hackageindex using the instructions on http://next.hackage.haskell.org:8080/ - Run 
cabal update - Look at the files in 
~/.cabal/packages/next-hackage, and manually reset their file modification times to some point far in the past (e.g., more than Cabal's update threshold.) - Run 
cabal install. You should get an out of date warning. - Run 
cabal udpate 
Expected result: No more out of date warning
Actual result: The warning persists
How to fix.
- First, you need to find where this warning is being emitted. If you grep for the message string you can find it.
 - You'll find the message is emitted in 
cabal-install/Distribution/Client/IndexUtils.hs, according to the conditional here: 
    isOldThreshold = 15 --days
    warnIfIndexIsOld dt = do
      when (dt >= isOldThreshold) $ case repo of
        RepoRemote{..} -> warn verbosity $ errOutdatedPackageList repoRemote dt
        RepoSecure{..} -> warn verbosity $ errOutdatedPackageList repoRemote dt
        RepoLocal{..}  -> return ()
- 
By tracing the code flow, we see
warnIfIndexIsOld =<< getIndexFileAge repo, where getIndexFileAge looks at the file modification time. This means that the problem is likely thatcabal updateis not updating the modification time on a file when it updates and sees no update is necessary. - 
The code for updating on
cabal updateis incabal-install/Distribution/Client/Update.hsinupdateRepo. You will need to update this code to update the file mod time EVEN when there were no updates. You should at least handle theRepoSecurecase but it may also be worth fixingRepoRemote - 
Check and make sure that the bug has gone away. It's not necessary to write a test (we don't really have infrastructure for mucking about the clock in cabal-install.)
 
What you will learn. How to build and develop Cabal. How to setup external repositories in Cabal. How index updates work in Cabal.
I have next-hackage configured, which changes rarely.
If I do a configure, I get the following warning
Warning: The package list for 'next-hackage' is 16 days old.
Run 'cabal update' to get the latest list of available packages.
despite having just done one.
Perhaps there should be a local record of when last an update was done, with a grace period on the warning based on that.