Installing hledger
I became interested in Plain Text Accounting and decided to install hledger to see how to start using it. I failed to install it the first time due to this message:
$ stack install --resolver=lts-19 hledger-lib-1.28 hledger-1.28 hledger-ui-1.28 hledger-web-1.28
Selected resolver: lts-19.33
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for hledger-ui-1.28:
brick-0.68.1 from stack configuration does not match >=1.5 (latest matching version is 1.6)
fsnotify-0.3.0.1 from stack configuration does not match >=0.4 && <0.5 (latest matching version is 0.4.1.0)
needed since hledger-ui is a build target.
Some different approaches to resolving this:
* Set 'allow-newer: true' in /home/jbrains/.stack/config.yaml to ignore all version constraints and build anyway.
* Recommended action: try adding the following to your extra-deps in /home/jbrains/.stack/global-project/stack.yaml:
- brick-1.6@sha256:4a94b18be68d2d27da9e84eff7f8b4dc8bfa3a40d28d536fb737828d73a0e3eb,18899
- fsnotify-0.4.1.0@sha256:44540beabea36aeeef930aa4d5f28091d431904bc9923b6ac4d358831c651235,2854
Plan construction failed.
Since I don’t know ghcup
at all, I was stuck. I managed to piece together an answer: specify the additional packages in the command, so that stack
would install them.
$ stack install --resolver=lts-20.8 hledger-lib-1.28 hledger-1.28 hledger-ui-1.28 hledger-web-1.28 brick-1.5 fsnotify-0.4.0.0
This installed hledger
and now I have a new task to spend a few hours figuring out what I can do with it.
Notice the version numbers of the various packages, which don’t exactly match the installation documentation nor the “Recommended action” in the installation failure message.
How I Knew…
I couldn’t figure out how to specify the additional packages simply. I didn’t want to change a magic global configuration file, so I inferred that there must be a way to specify the extra packages as part of the stack install
command.
I read the section of the install documentation entitled “Build with hledger-install”, which directed me to read the installation script. When I did this, I noticed some helpful-looking package version numbers.
# the oldest version of stack that might possibly work: perhaps 2.5.1
STACK_MIN_VERSION=2.5.1
# stackage snapshot to use when installing with stack.
# You can try specifying a different stackage version here, or
# commenting out this line to use your current global resolver,
# to avoid unnecessary building.
STACK_RESOLVER="--resolver=lts-20.8"
# Dependencies we require that aren't in the above stackage snapshot.
# (Also requested when using cabal, but that's harmless.)
STACK_EXTRA_DEPS="\
brick-1.5 \
fsnotify-0.4.0.0 \
"
This suggested to me that I ought to try a different resolver version (lts-20.8
instead of lts-19
) and these particular package versions for brick
and fsnotify
.
After reading through the installation script, I realized—and felt mildly stupid about this—that I needed merely to specify the additional packages with their version numbers as packages to install. (I had kept looking for some “extra dependencies” command-line argument and couldn’t find it!) That led me to the winning command.
As of today, these versions of the various tools worked for me on Pop!_OS 22.04.
- ghc 9.2.5
- stack 2.9.1
- resolver lts-20.8
- hledger-* 1.28
- brick-1.5
- fsnotify-0.4.0.0
I have no idea how long this information will remain relevant and accurate.