commercialhaskell / commercialhaskell/stack

Enable cleaning up snapshots

Open
#6,084 5 comments 1 reaction 0 assignees View on GitHub
type: enhancement
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

**Problem**

I want to clean up old snapshots I'm not using. e.g. delete all snapshots older than 30 days:

```bash
find ~/.stack/snapshots/aarch64-osx -depth 1 -mtime +30 | xargs rm -rf
```

But if Stack detects a package can be reused (i.e. when it says "using precompiled package"), it will simply point to the artifacts in another snapshot (in the paths in `pkgdb/foo.conf`). So if I delete an old snapshot that a newer snapshot has packages pointing to it, Stack will fail to build.

**Possible solutions**

1. Have Stack automatically detect packages with links to non-existent snapshots + rebuild
2. Add command to do ^
3. Add command to denormalize packages
* e.g. copy artifacts from old snapshot to new snapshot + update paths
* can run before deleting snapshots

**Current workarounds**

Manually run `ghc-pkg unregister`, I think? Haven't tried

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.