[commit: ghc] master: Improve outdated ghc-pkg cache warning (#9606) (e7fab33)

git at git.haskell.org git at git.haskell.org
Wed Feb 18 15:48:16 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/e7fab334b31dc516d2e8f2285630cbffe9825b76/ghc

>---------------------------------------------------------------

commit e7fab334b31dc516d2e8f2285630cbffe9825b76
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Tue Feb 17 08:39:35 2015 -0600

    Improve outdated ghc-pkg cache warning (#9606)
    
    Summary: No more frustration.
    
    Test Plan: I tested it.
    
    Reviewers: austin
    
    Reviewed By: austin
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D658
    
    GHC Trac Issues: #9606


>---------------------------------------------------------------

e7fab334b31dc516d2e8f2285630cbffe9825b76
 utils/ghc-pkg/Main.hs | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs
index b2815b8..53bc43b 100644
--- a/utils/ghc-pkg/Main.hs
+++ b/utils/ghc-pkg/Main.hs
@@ -706,7 +706,7 @@ readParseDatabase verbosity mb_user_conf modify use_cache path
                       then do
                         warn ("WARNING: cache does not exist: " ++ cache)
                         warn ("ghc will fail to read this package db. " ++
-                              "Use 'ghc-pkg recache' to fix.")
+                              recacheAdvice)
                       else do
                         warn ("WARNING: cache cannot be read: " ++ show ex)
                         warn "ghc will fail to read this package db."
@@ -736,7 +736,7 @@ readParseDatabase verbosity mb_user_conf modify use_cache path
                           whenReportCacheErrors $ do
                               warn ("WARNING: cache is out of date: " ++ cache)
                               warn ("ghc will see an old view of this " ++
-                                    "package db. Use 'ghc-pkg recache' to fix.")
+                                    "package db. " ++ recacheAdvice)
                           ignore_cache compareTimestampToCache
             where
                  ignore_cache :: (FilePath -> IO ()) -> IO PackageDB
@@ -753,6 +753,12 @@ readParseDatabase verbosity mb_user_conf modify use_cache path
                      when (   verbosity >  Normal
                            || verbosity >= Normal && not modify)
   where
+    recacheAdvice
+      | Just (user_conf, True) <- mb_user_conf, path == user_conf
+      = "Use 'ghc-pkg recache --user' to fix."
+      | otherwise
+      = "Use 'ghc-pkg recache' to fix."
+
     mkPackageDB pkgs = do
       path_abs <- absolutePath path
       return PackageDB {



More information about the ghc-commits mailing list