LinuxmacOSWindows

Where Does Cabal Store Packages and Config?

Modern Cabal splits config, cache, and store across XDG homes, with ~/.cabal kept as the legacy fallback.

Last updated

Current Cabal follows the XDG base directories: config in ~/.config/cabal, downloaded packages in ~/.cache/cabal, and the compiled store in ~/.local/state/cabal. The old single ~/.cabal tree still wins when it exists, which is why two machines disagree about where everything went.

CABAL_DIR overrides the entire scheme at once, and CABAL_CONFIG moves just the config file. Deleting the cache rebuilds safely. Deleting the state store breaks installed executables until they rebuild, so prefer cabal's own cleanup for space.

Where Cabal stores this, by platform

Linux
~/.config/cabal/config + ~/.cache/cabal + ~/.local/state/cabal

Config, package cache, and compiled store under XDG homes. If ~/.cabal exists from an older install it takes over everything instead. Set CABAL_DIR to relocate the whole tree, CABAL_CONFIG for the config file alone.

macOS
~/.config/cabal/config + ~/.cache/cabal + ~/.local/state/cabal

Same XDG layout as Linux. GHC itself lives under ~/.ghcup beside it. Xcode command line tools must exist for anything to link. Legacy ~/.cabal takes precedence when present.

Windows
%APPDATA%\cabal (config, packages, store)

Single tree under Roaming AppData on Windows. CABAL_DIR and CABAL_CONFIG overrides work the same. Long path limits bite deep store trees, so keep the tree short or enable long paths when builds fail on filenames.

Frequently asked questions

Can I delete Cabal's cache to free disk space?

Yes for ~/.cache/cabal. Its contents reconstruct on demand. Leave the state store alone unless you accept rebuilding installed tools. Check which tree is actually live first, since legacy ~/.cabal shadows the XDG paths when it exists.

Why does Cabal use ~/.cabal on one machine and XDG paths on another?

Backwards compatibility. An existing ~/.cabal directory forces the old single tree layout. Remove or migrate it to switch a machine to XDG homes. CABAL_DIR set anywhere overrides both schemes entirely.

Notice an outdated path? Let us know.