How to uninstall a Haskell package installed with stack?

Kwang Yul Seo picture Kwang Yul Seo · Jul 28, 2016 · Viewed 11.2k times · Source

How can I uninstall a Haskell package installed globally with stack tool?

stack --help shows that uninstall command is deprecated.

  uninstall                DEPRECATED: This command performs no actions, and is
                           present for documentation only

Answer

jkeuhlen picture jkeuhlen · Jul 28, 2016

As stack --help says, uninstall doesn't do anything. You can read about this on the stack github where this feature was requested, but it ended up being closed without the desire to add the behavior to stack, for various reasons. So, officially, there is no way to use stack to uninstall a package.

To remove a package that stack installed, you need to manually do so. This entails using ghc-pkg unregister and then finding the location of the package on your system and removing it via another tool or simply rm. For example,

stack install <package name>
# Now remove the package
ghc-pkg unregister <pkg-id>
cd /path/to/stack/packages # This could be something like ~/.local/bin, but is configuration dependent
rm <package name>