stack-clean-old: Clean away old stack build artefacts

[ bsd3, distribution, program ] [ Propose Tags ]

A tool for cleaning away old .stack snapshots and .stack-work builds to recover diskspace.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1, 0.2, 0.2.1, 0.2.2, 0.3, 0.3.1, 0.4, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.4.5, 0.4.6, 0.4.7, 0.4.8, 0.5, 0.5.1
Change log ChangeLog.md
Dependencies base (>=4.8 && <5), directory (>=1.2.5), extra (>=1.4.3), filemanip, filepath, simple-cmd (>=0.1.4), simple-cmd-args (>=0.1.2) [details]
License BSD-3-Clause
Copyright 2020 Jens Petersen <juhpetersen@gmail.com>
Author Jens Petersen <juhpetersen@gmail.com>
Maintainer Jens Petersen <juhpetersen@gmail.com>
Category Distribution
Home page https://github.com/juhp/stack-clean-old
Bug tracker https://github.com/juhp/stack-clean-old/issues
Source repo head: git clone https://github.com/juhp/stack-clean-old.git
Uploaded by JensPetersen at 2020-12-31T08:35:17Z
Distributions LTSHaskell:0.5.1, NixOS:0.5.1, Stackage:0.5.1
Executables stack-clean-old
Downloads 1897 total (49 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2020-12-31 [all 2 reports]

Readme for stack-clean-old-0.2.2

[back to package description]

stack-clean-old

A small tool to clean away older Haskell stack snapshot builds and ghc versions, to recover diskspace.

Usage

stack-clean-old [project|snapshots|ghc] [size|list|remove-version|remove-earlier-minor] [GHCVER]

These commands act respectively on:

  • the current local project: .stack-work/install/
  • the user's stack snapshot builds: ~/.stack/snapshots/
  • installed stack ghc compilers: ~/.stack/programs/.

and the subcommands:

size: prints the total size of the above directory (size does not take a GHCVER argument).

list: shows the total size and number of snapshots per ghc version (the GHCVER argument is optional).

remove-version: removes all snapshots for the specified ghc version (the GHCVER argument is required).

remove-earlier-minor: removes the builds/installs for previous minor ghc versions. If GHCVER is given then only minor versions older than it are removed.

NB: If you remove all snapshot builds for a version of ghc, then you would have to rebuild again for any projects still using them, so removal should be used cautiously, but it can recover a lot of diskspace.

NBB: All the command support --dryrun (-n) so you can check the effect of running them safely beforehand.

Example usage

To remove project builds for ghc-8.2.2:

$ stack-clean-old project list
154M  8.2.2  (5 dirs)
154M  8.4.4  (5 dirs)
163M  8.6.5  (5 dirs)
$ stack-clean-old project remove-version 8.2.2

Remove all stack ghc-8.4 snapshot builds before 8.4.4:

$ stack-clean-old snapshots list 8.4
421M  8.4.1  (7 dirs)
368M  8.4.2  (6 dirs)
489M  8.4.3  (8 dirs)
799M  8.4.4  (24 dirs)
$ stack-clean-old snapshots remove-earlier-minor 8.4.4
7 dirs removed for 8.4.1
6 dirs removed for 8.4.2
8 dirs removed for 8.4.3

Incidently I build my projects across as many major Stackage LTS versions as possible, and collectively this piles up to a lot of diskspace: so I wrote this tool to help manage that.

Purging older stack project builds

stack-clean-old project remove-older

This command removes older stack builds from .stack-work/install/. By default it keeps 5 newest builds per ghc version.

The preservation/deletion is calculated and done per ghc version.

NB: If you regularly build your project for several branches/tags against the same LTS or ghc version then it is safer to avoid using remove-older.

Also stack-clean-old project remove-work can be used to recursively remove all .stack-work/ dirs from a project to save space.

Installation

Run stack install or cabal install

Contributing

BSD license

Project: https://github.com/juhp/stack-clean-old

Warning disclaimer

Use at your own risk.

The author takes no responsibility for any loss or damaged caused by using this tool.

Bug reports, suggestions, and improvements are welcome.