Everywhere that GHC/Haskell Platform installs

╄→гoц情女王★ 提交于 2019-11-28 16:24:15
pithyless

Had to remove Haskell Platform on OS X recently. Most are cleaned up via Uninstaller:

sudo /Library/Frameworks/GHC.framework/Versions/Current/Tools/Uninstaller

These have to be cleaned up manually:

rm -r ~/.cabal
rm -r ~/.ghc
rm -r ~/Library/Haskell

Alternatively, as documented in

/Library/Haskell/doc/start.html

there is now a custom uninstall command with options,

/Library/Haskell/bin/uninstall-hs

In general, one can document the files created by any activity (installer, ...) by bracketing the activity in a work directory with

echo >timestamp
[activity]
sudo find -x / -newer timestamp -print >snapshot.txt

If you've installed a Haskell Platform since about 2012 on OS X, just run

uninstall-hs

and carefully read what it outputs. You'll need to run it again with the options it offers you. Run

uninstall-hs --help

for more options.


Below is my original answer, which will still work, but doesn't offer as many options and is a bit "ham fisted":

Warning: This script is extreme. It will remove even your custom config files for GHC and Cabal, and executables you've built that are still in ~/Library/Haskell or ~/.cabal. Use caution; review what it is about to do; have backups; caveat scriptor!

#!/bin/bash
set -x

sudo rm -rf /Library/Frameworks/GHC.framework
sudo rm -rf /Library/Frameworks/HaskellPlatform.framework
sudo rm -rf /Library/Haskell
rm -rf ~/.cabal
rm -rf ~/.ghc
rm -rf ~/Library/Haskell
find /usr/bin /usr/local/bin -type l | \
  xargs -If sh -c '/bin/echo -n f /; readlink f' | \
  egrep '//Library/(Haskell|Frameworks/(GHC|HaskellPlatform).framework)' | \
  cut -f 1 -d ' ' > /tmp/hs-bin-links
sudo rm -f `cat /tmp/hs-bin-links`

You may want to add lines to save off and restore your config files like:

mv ~/.cabal/config /tmp/cabal-config 2>/dev/null || true
mv ~/.ghc/gchi.conf /tmp/ghci-config 2>/dev/null || true

and

mkdir ~/.cabal
mkdir ~/.ghc
cp /tmp/cabal-config ~/.cabal/config 2>/dev/null || true
cp /tmp/ghci-config ~/.ghc/gchi.conf 2>/dev/null || true

Bracket the rm lines with these. Though you may or may not want your old ~/.cabal/config if you are upgrading to newer stuff.

Note that this only deals with the current user's home directory. If you have multiple user accounts that all use Haskell, then the other accounts will need cleaning as well. (Repeat the lines involving ~.)

I am on OSX (Lion atm). I've got GHC in /Library/Frameworks/GHC.framework/ (current and previous versions). There are also some symlinks in /usr/bin, but these will be replaced by a new install.

If you have used cabal to (locally) install packages, you also may want to clean out ~/.cabal. If you have a recent cabal, you can easily reinstall all packages for the 'new' GHC version by using cabal install world and then look for directories matching previous version of GHC you had like so:

for package in `ls ~/.cabal/lib/`; do 
   if [ ! -d ~/.cabal/lib/${package}/ghc-7.0.3 ]; then 
       echo $package; 
   else 
       echo "OK for $package"; 
   fi;
done 

These should be safe to delete.

Hope this helps you somewhat.

uninstall-hs does some of the work for you; I'm not sure how much.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!