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

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

A tool for removing old .stack-work/install builds and .stack/snapshots & programs for older ghc versions to recover diskspace.


[Skip to Readme]

Properties

Versions 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.3, 0.4.4, 0.4.5, 0.4.6
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-2021 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 2021-11-23T12:57:36Z

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for stack-clean-old-0.4.3

[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 [size|list|remove|keep-minor|purge-older|delete-work] [-d|--delete] [(-p|--project) | (-g|--ghc)] [GHCVER]

Options:

and the subcommands:

size: prints the total size of the above directories (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: removes for the specified ghc version (the GHCVER argument is required).

keep-minor: removes the builds/installs for older minor releases of ghc major versions. If GHCVER is given then only minor versions older than it are removed.

purge-older and delete-work: see sections below

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

Since version 0.4 dry-run mode is now the default and one needs to use --delete (-d) for actual deletion of files, after checking the dry-run output first.

Example usage

List a project's builds:

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

Remove project's 8.2.2 builds:

$ stack-clean-old remove --delete --project 8.2.2
:

(--project is optional in a project dir).

Remove stack ghc-8.4 snapshot builds and compilers before 8.4.4:

$ stack-clean-old list --global 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 keep-minor -d -g 8.4.4
ghc-tinfo6-8.4.3 removed
7 dirs removed for 8.4.1
6 dirs removed for 8.4.2
8 dirs removed for 8.4.3

(--global is optional outside a project dir).

Purging older stack project builds

stack-clean-old purge-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 purge-older.

Deleting all .stack-work/ subdirectories

stack-clean-old delete-work --recursive can be used to remove recursively all .stack-work/ dirs from a project to save space (seems same as stack clean --full).

stack-clean-old delete-work --all works from outside stack projects: please use with care with --delete.

Help output

(Note you can also run this tool via stack clean-old.)

To get help you can run stack-clean-old --help or just:

$ Stack clean up tool

Usage: stack-clean-old [--version] COMMAND
  Cleans away old stack-work builds (and pending: stack snapshots) to recover
  diskspace. Use the --delete option to perform actual removals.
  https://github.com/juhp/stack-clean-old#readme

Available options:
  -h,--help                Show this help text
  --version                Show version

Available commands:
  size                     Total size
  list                     List sizes per ghc version
  remove                   Remove for a ghc version
  keep-minor               Remove for previous ghc minor versions
  purge-older              Purge older builds in .stack-work/install
  delete-work              Remove project's .stack-work/ (optionally
                           recursively)

Installation

Run stack install or cabal install

This tool complements stack-all which builds projects across LTS major versions and hence generates a lot of stack builds.

cabal-clean is a similar tool for cleaning old cached cabal build files.

Contributing

BSD license

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

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.