Related materials:
Background
Once a dependency gets installed into Stack's compiled package database ~/.stack/snapshots, it gets aggressively cached for as long as the snapshot hash keeps matching. This is as designed and as desired:
$ stack install lzma
[...]
$ stack exec -- ghc-pkg unregister lzma
$ stack install lzma
lzma> using precompiled package
$
This using precompiled package log (and the fast build) — is exactly as expected.
The issue
It's hard to surgically yank one package/subtree from this precompiled_cache. I met reasons to want to do this many times; will give one below.
Despite stack install offering the --[no-]force-dirty option, it's not effective for this purpose, and behaves the same:
$ stack exec -- ghc-pkg unregister lzma
$
$ stack install --force-dirty lzma
lzma> using precompiled package
$
Expected: fresh rebuild of the lzma package. Actual: using precompiled package again.
Thus, the most precise option to force a rebuild of one dependency is still "nuclear":
- identify the active snapshot hash, e.g.
stack exec -- ghc-pkg list | grep /pkgdb,
- drop the entire snapshot,
rm -rf ~/.stack/snapshots/{{arch}}/{{hash}}.
More precision is doable with pointwise file removals and DELETE FROM precompiled_cache WHERE library LIKE '%/lzma-%'; — but this feels like violating API boundaries & messing with internal guts. I think anyone would prefer if --force-dirty would instead do that.
Sample rationale
Unlike other linkers, MacOS ld warns about nonexistent -L paths. A real-world scenario I sorted out today proceeded like this:
xz library 5.8.1 installed via Homebrew at /opt/homebrew/Cellar/xz/5.8.1;
- A Haskell project having lzma (a libxz FFI wrapper) in transitive dependency closure was built;
xz library upgraded in Homebrew to 5.8.3, /opt/homebrew/Cellar/xz/5.8.3.
Ever since, rebuilds of the Haskell project had been repeatedly emitting:
ld: warning: search path '/opt/homebrew/Cellar/xz/5.8.1/lib' not found
because ~/.stack/snapshots/aarch64-osx/4426a...775284/9.6.7/pkgdb/lzma-0.0.1.1-obp6...LW.conf contains include-dirs: /opt/homebrew/Cellar/xz/5.8.1/include which no longer exists (the 5.8.3 one does).
Wiping the project's .stack-work was not effective to clear the warning, neither git clean -fxd. Such a minor issue, yet necessarily invokes nuclear wipes to enact an eviction of a cached build which went stale, for external reasons.
Tested on:
$ stack --version
Version 3.11.1, Git revision 2352d78a8ac5b42d021c8064b8f64ac1c8b8b3d5 aarch64 hpack-0.39.6
from GHCup.
Related materials:
Background
Once a dependency gets installed into Stack's compiled package database
~/.stack/snapshots, it gets aggressively cached for as long as the snapshot hash keeps matching. This is as designed and as desired:This
using precompiled packagelog (and the fast build) — is exactly as expected.The issue
It's hard to surgically yank one package/subtree from this precompiled_cache. I met reasons to want to do this many times; will give one below.
Despite
stack installoffering the--[no-]force-dirtyoption, it's not effective for this purpose, and behaves the same:Expected: fresh rebuild of the lzma package. Actual:
using precompiled packageagain.Thus, the most precise option to force a rebuild of one dependency is still "nuclear":
stack exec -- ghc-pkg list | grep /pkgdb,rm -rf ~/.stack/snapshots/{{arch}}/{{hash}}.More precision is doable with pointwise file removals and
DELETE FROM precompiled_cache WHERE library LIKE '%/lzma-%';— but this feels like violating API boundaries & messing with internal guts. I think anyone would prefer if--force-dirtywould instead do that.Sample rationale
Unlike other linkers, MacOS
ldwarns about nonexistent-Lpaths. A real-world scenario I sorted out today proceeded like this:xzlibrary 5.8.1 installed via Homebrew at /opt/homebrew/Cellar/xz/5.8.1;xzlibrary upgraded in Homebrew to 5.8.3, /opt/homebrew/Cellar/xz/5.8.3.Ever since, rebuilds of the Haskell project had been repeatedly emitting:
because
~/.stack/snapshots/aarch64-osx/4426a...775284/9.6.7/pkgdb/lzma-0.0.1.1-obp6...LW.confcontainsinclude-dirs: /opt/homebrew/Cellar/xz/5.8.1/includewhich no longer exists (the 5.8.3 one does).Wiping the project's
.stack-workwas not effective to clear the warning, neithergit clean -fxd. Such a minor issue, yet necessarily invokes nuclear wipes to enact an eviction of a cached build which went stale, for external reasons.Tested on:
from GHCup.