haskell / haskell/cabal

Add sub-command 'purge'

Open
#2,151 2 comments 0 reactions 0 assignees View on GitHub
cabal-install: other old-milestone: cabal-install 2.0 type: enhancement
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

I often see people on IRC and elsewhere suggesting that people `rm -rf ~/.cabal` which is far from optimal and actually in-sufficient.

I can however see the need to manually do _something_ before doing a complete `cabal install `, particularly for yesod based projects.

I am therefore proposing a `cabal purge` command that would DoTheRightThing(tm) so that people can say "just run `cabal purge`" instead of something more complicated and potentially wrong.

The `cabal purge` command would do the following:
- If there is a cabal.sandbox.config file, read it to get the cabal-sandbox location and the remove the directory:

```
${cabal-sandbox-location}/lib/${arch}-${os}-{$ghc_version}
```
- If there is no cabal sandbox config file, remove the directories:

```
~/.cabal/lib/${arch}-${os}-{$ghc_version}
~/.ghc/${arch}-${os}-{$ghc_version}
```

In each of the above two cases cabal would print:

``````
```
About to delete directories ...... [y/n]
```
``````

and when done print the age (see #2150) of the cabal index file.

Comments? Suggestions?

Contributor guide

Open the contributing guide

Research direction

Start by locating cabal-install's command dispatch and sandbox configuration handling, then trace how cabal.sandbox.config identifies the sandbox location. Define the purge behavior for sandboxed and non-sandboxed projects, including confirmation prompts, architecture/GHC-specific paths, and reporting the cabal index age; the issue references #2150 for that age information.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.