How to remove a cabal package from the local system?

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/hackage.haskell.org, but the defective version isn't included. bye V.W.

I use a shell script. It's really useful, surely there's some
official way to do this?
#!/bin/zsh
package=$1
if ! ghc-pkg describe $package >/dev/null; then
echo no such package: $package
exit 1
fi
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
fi
rm -rf $libdir $hidir $html
fi
On Wed, Jan 21, 2015 at 11:36 PM, Volker Wysk
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/hackage.haskell.org, but the defective version isn't included.
bye V.W. _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Am Mittwoch, 21. Januar 2015, 23:56:53 schrieben Sie:
I use a shell script. It's really useful, surely there's some official way to do this?
It looks like a "remove" command to "cabal" has been forgotten... This would be a feature request. I'm also missing a command to set the "Default available version". Thanks for the script! Volker

On Wed, Jan 21, 2015 at 11:19 AM, Volker Wysk
I'm also missing a command to set the "Default available version".
You don't set that; it's specified in the downloaded package index in the package repo. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On 2015-01-21 at 16:36:08 +0100, Volker Wysk wrote:
I have installed/registered a new version of a package with cabal by accident. How can I remove it again?
Not sure if this is what you want, but the `cab` tool has an `uninstall` sub-command to unregister and remove installed packages. [1]: http://hackage.haskell.org/package/cab

Am Mittwoch, 21. Januar 2015, 19:39:50 schrieben Sie:
On 2015-01-21 at 16:36:08 +0100, Volker Wysk wrote:
I have installed/registered a new version of a package with cabal by accident. How can I remove it again?
Not sure if this is what you want, but the `cab` tool has an `uninstall` sub-command to unregister and remove installed packages.
Yes, this is what I want. But Evan's script works fine. I think I will stick to it. Greeting Volker

On 2015-01-22 at 09:04:30 +0100, Volker Wysk wrote:
I have installed/registered a new version of a package with cabal by accident. How can I remove it again?
Not sure if this is what you want, but the `cab` tool has an `uninstall` sub-command to unregister and remove installed packages.
Yes, this is what I want. But Evan's script works fine. I think I will stick to it.
There's one thing though that Evan's script doesn't handle afaics: recursive de-installation of packages that depend upon the package version you're uninstalling... Hopefully at some point `cabal` will provide a `uninstall` command out of the box, you can subscribe to the respective GitHub issue if you want to follow that discussion: https://github.com/haskell/cabal/issues/227 Cheers, hvr

On 2015-01-21 10:36 AM, Volker Wysk wrote:
I have installed/registered a new version of a package with cabal by accident. How can I remove it again?
See my http://www.vex.net/~trebla/haskell/sicp.xhtml#remove . In fact, read the whole thing.

Am Donnerstag, 22. Januar 2015, 11:19:37 schrieb Albert Y. C. Lai:
On 2015-01-21 10:36 AM, Volker Wysk wrote:
I have installed/registered a new version of a package with cabal by accident. How can I remove it again?
See my http://www.vex.net/~trebla/haskell/sicp.xhtml#remove . In fact, read the whole thing.
This describes what Evan is doing in his script. Bye Volker
participants (5)
-
Albert Y. C. Lai
-
Brandon Allbery
-
Evan Laforge
-
Herbert Valerio Riedel
-
Volker Wysk