Reputation: 202465
Happstack Lite is breaking on me because it's getting blaze-html version 0.5 and it wants version 0.4. Cabal says that both versions 0.4.3.4 and 0.5.0.0 are installed. I want to remove the 0.5.0.0 and use just the older version. But cabal does not have an "uninstall" command, and when I try ghc-pkg unregister --force blaze-html
, ghc-pkg
says my command has been ignored.
What do I do?
UPDATE: Don't believe it. Although ghc-pkg
claims to ignore the command, the command isn't ignored. And with Don Stewart's accepted answer you can remove exactly the version you wish to eliminate.
Upvotes: 86
Views: 48182
Reputation: 34288
If you are outside a sandbox:
ghc-pkg unregister --force regex-compat-0.95.1
If you are inside a cabal sandbox:
cabal sandbox hc-pkg -- unregister attoparsec --force
The first --
is the argument separator for hc-pkg
. This runs ghc-pkg
in a sandbox aware manner.
Upvotes: 22
Reputation: 137937
You can ghc-pkg unregister
a specific version, like so:
$ ghc-pkg unregister --force regex-compat-0.95.1
That should be sufficient.
Upvotes: 96
Reputation: 7444
There is also the cabal-uninstall package which provides a cabal-uninstall
command. It unregisters the package and deletes the folder. It is worth mentioning though that it passes --force
to ghc-pkg unregister
so it can break other packages.
Upvotes: 20
Reputation: 6991
Here's a shell script I use to uninstall a package. It supports multiple installed versions of GHC and also wipes relevant files (but is provided without warranty, don't blame me if you hose your installation!)
#!/bin/bash -eu
# Usage: ./uninstall.sh [--force | --no-unregister] pkgname-version
# if you set VER in the environment to e.g. "-7.0.1" you can use
# the ghc-pkg associated with a different GHC version
: ${VER:=}
if [ "$#" -lt 1 ]
then
echo "Usage: $0 [--force | --no-unregister] pkgname-version"
exit 1
fi
if [ "$1" == "--force" ]
then force=--force; shift; # passed to ghc-pkg unregister
else force=
fi
if [ "$1" == "--no-unregister" ]
then shift # skip unregistering and just delete files
else
if [ "$(ghc-pkg$VER latest $1)" != "$1" ]
then
# full version not specified: list options and exit
ghc-pkg$VER list $1; exit 1
fi
ghc-pkg$VER unregister $force $1
fi
# wipe library files
rm -rfv -- ~/.cabal/lib/$1/ghc-$(ghc$VER --numeric-version)/
# if the directory is left empty, i.e. not on any other GHC version
if rmdir -- ~/.cabal/lib/$1
then rm -rfv -- ~/.cabal/share/{,doc/}$1 # then wipe the shared files as well
fi
Upvotes: 7