How can I uninstall a version of a Cabal package?
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.
Solution 1:
You can ghc-pkg unregister
a specific version, like so:
$ ghc-pkg unregister --force regex-compat-0.95.1
That should be sufficient.
Solution 2:
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.
Solution 3:
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.