Skip to content

Instantly share code, notes, and snippets.

@simonmichael
Created September 1, 2011 03:59
Show Gist options
  • Star 78 You must be signed in to star a gist
  • Fork 17 You must be signed in to fork a gist
  • Save simonmichael/1185421 to your computer and use it in GitHub Desktop.
Save simonmichael/1185421 to your computer and use it in GitHub Desktop.
ghc-pkg-clean, ghc-pkg-reset
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages.
# ghc-pkg-clean -f cabal/dev/packages*.conf also works.
function ghc-pkg-clean() {
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'`
do
echo unregistering $p; ghc-pkg $* unregister $p
done
}
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place.
# When all else fails, use this to get out of dependency hell and start over.
function ghc-pkg-reset() {
read -p 'erasing all your user ghc and cabal packages - are you sure (y/n) ? ' ans
test x$ans == xy && ( \
echo 'erasing directories under ~/.ghc'; rm -rf `find ~/.ghc -maxdepth 1 -type d`; \
echo 'erasing ~/.cabal/lib'; rm -rf ~/.cabal/lib; \
# echo 'erasing ~/.cabal/packages'; rm -rf ~/.cabal/packages; \
# echo 'erasing ~/.cabal/share'; rm -rf ~/.cabal/share; \
)
}
alias cabalupgrades="cabal list --installed | egrep -iv '(synopsis|homepage|license)'"
@timmytofu
Copy link

I modified your ghc-pkg-reset shell function to work on zsh as well as bash if you're interested:

https://gist.github.com/timmytofu/7417408

@p-alik
Copy link

p-alik commented Feb 4, 2017

@timmytofu, read build-in in zsh doesn't accept -p flag.
Then /proc is Linux virtual fs. FreeBSD - and other too - doesn't use it.
Here an other attempt to get rid of OS specifics
https://gist.github.com/p-alik/4f8cc64ace8a20a8bebcb8e8e1cba2a4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment