How to remove a cabal package from the local system?

Evan Laforge qdunkan at
Wed Jan 21 15:56:53 UTC 2015

I use a shell script.  It's really useful, surely there's some
official way to do this?



if ! ghc-pkg describe $package >/dev/null; then
    echo no such package: $package
    exit 1

ghcdir=$(ghc --print-libdir)

function field() {
    ghc-pkg field $package $1 | cut -d' ' -f2-
    return $?

libdir=$(field library-dirs)
hidir=$(field import-dirs)
html=$(dirname $(field haddock-html))

echo rm -rf $libdir $hidir $html
echo -n 'remove? '
read response
if [[ $response = y ]]; then
    # ghc-pkg unregister will complain if this will break other packages
    if ! ghc-pkg unregister $package; then
        exit 1
    rm -rf $libdir $hidir $html

On Wed, Jan 21, 2015 at 11:36 PM, Volker Wysk <verteiler at> wrote:
> Hi!
> I have installed/registered a new version of a package with cabal by accident.
> How can I remove it again?
> There is something in ~/.cabal/packages/, but the defective
> version isn't included.
> bye
> V.W.
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at

More information about the Glasgow-haskell-users mailing list