Skip to content

Cabal reports index is out of date based on index time, not last update time #4444

Closed

Description

@alanz

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.

  1. Configure the next-hackage index using the instructions on http://next.hackage.haskell.org:8080/
  2. Run cabal update
  3. 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.)
  4. Run cabal install. You should get an out of date warning.
  5. Run cabal udpate

Expected result: No more out of date warning
Actual result: The warning persists

How to fix.

  1. First, you need to find where this warning is being emitted. If you grep for the message string you can find it.
  2. 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 ()

  1. 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 that cabal update is not updating the modification time on a file when it updates and sees no update is necessary.

  2. The code for updating on cabal update is in cabal-install/Distribution/Client/Update.hs in updateRepo. You will need to update this code to update the file mod time EVEN when there were no updates. You should at least handle the RepoSecure case but it may also be worth fixing RepoRemote

  3. 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.

Activity

  1. ezyang commented on Apr 8, 2017

    @ezyang
    Contributor

    Good idea.

  2. 23Skidoo commented on Apr 10, 2017

    @23Skidoo
    Member

    Yep, I'm also affected by this.

  3. hvr commented on Apr 11, 2017

    @hvr
    Member

    ...just came here to say that I like the ticket number =)

    PS: ...and I agree that keeping track of the last cabal update attempt makes sense...

  4. changed the title [-]Erroneous update warning[/-] [+]Cabal reports index is out of date based on index time, not last update time[/+] on May 7, 2017
  5. added a commit that references this issue on Dec 11, 2017
    c2cf116
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions