Clean and reinstall those GHC packages!

November 18, 2011

For those of you who are as lazy as me about fixing and reinstalling broken GHC packages, I’ve ripped off the well-known and loved ghc-pkg-clean script and made it recursive.  No promises of termination:
 
function ghc-pkg-supercleaner() {
    b="0"
    for p in `ghc-pkg check $* 2>&1  | grep problems | awk '{print $6}' | sed -e 's/:$//'`
    do
        echo unregistering $p; ghc-pkg $* unregister $p;
        cabal install $p; b="1"
    done
    if [ $b == "1" ];
      then ghc-pkg-supercleaner
    fi
}
About these ads

3 Responses to “Clean and reinstall those GHC packages!”


  1. For me, it gets stuck in an endless loop recompiling the text package over and over.

    • tommd Says:

      Not entirely surprising. It has worked well for me but I figure I’ll eventually hit a non-terminating case. Hence the disclaimer!

  2. Jens Petersen Says:

    Have you tried cab? It can do recursive removal of packages.

    Hopefully the next version of cabal-install should prevent package breaking by default.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: