Closed daniel-vainsencher closed 6 years ago
Thanks for the report.
It's very unfortunate, but any GHC-compiled haskell program encountering a non-ascii string, when there is no system locale configured, dies with unhelpful errors like this one. http://hledger.org/manual.html#troubleshooting and the man page BUGS sections mention this for users.
As you point out, it can be an issue during installation too. I suppose we must have some non-ascii in the docs, and these are now embedded into the haskell code at compile time. I'm having trouble reproducing it though. I did unset LANG, stack clean, ./Shake.hs docs, stack build hledger without problem.
Could you try stack --stack-yaml=stack-ghc8.yaml install hledger also. Perhaps GHC 8 will give a better error, revealing which tool it's coming from.
Added --verbose to that, think I got something that might be useful, see the bottom.
About
It's very unfortunate, but any GHC-compiled haskell program encountering a non-ascii string, when there is no system locale configured, dies with unhelpful errors like this one. How about using functions from [1] like getLocaleEncoding, which seems to test for UTF. Then two options are:
- Quit if locale is not UTF (but some might be sure enough all data is encoded in something their own local can deal with)
- Give a warning message when program starts up that "locale is
, will fail with message on non-conforming data". A third possibility (also imperfect) is to use setLocaleEncoding to just always work in UTF. I know GHC used to do that and stopped, but a policy that is too strong for system libraries might be reasonable for an application. Is UTF ever a bad choice for hledger? http://hledger.org/manual.html#troubleshooting and the man page BUGS sections mention this for users. I had no problem understanding what is happening exactly because I'd run across these before, but IMO informative error messages are much more friendly than out-of-band documentation.
Daniel
[1] https://hackage.haskell.org/package/base-4.8.0.0/docs/GHC-IO-Encoding.html
danielv@dvflair ~/private/local/hledger-orig master $ stack --stack-yaml=stack-ghc8.yaml install hledger --verbose Version 1.2.0 x86_64 Compiled with:
2016-10-22 09:06:26.499409: [debug] Loading project config file stack-ghc8.yaml @(Stack/Config.hs:810:13) 2016-10-22 09:06:26.502421: [debug] Trying to decode /home/danielv/.stack/build-plan-cache/x86_64-linux/lts-7.0.cache @(Data/Store/VersionTagged.hs:68:5) 2016-10-22 09:06:26.512435: [debug] Success decoding /home/danielv/.stack/build-plan-cache/x86_64-linux/lts-7.0.cache @(Data/Store/VersionTagged.hs:72:13) 2016-10-22 09:06:26.517917: [debug] Getting system compiler version @(Stack/Setup.hs:354:17) 2016-10-22 09:06:26.518241: [debug] Run process: /usr/bin/ghc --info @(System/Process/Read.hs:277:3) 2016-10-22 09:06:26.575967: [debug] Process finished in 57 ms: /usr/bin/ghc --info @(System/Process/Read.hs:277:3) 2016-10-22 09:06:26.579359: [debug] Asking GHC for its version @(Stack/Setup/Installed.hs:101:13) 2016-10-22 09:06:26.579645: [debug] Getting Cabal package version @(Stack/GhcPkg.hs:171:5) 2016-10-22 09:06:26.579805: [debug] Getting global package database location @(Stack/GhcPkg.hs:54:5) 2016-10-22 09:06:26.579906: [debug] Run process: /usr/bin/ghc --numeric-version @(System/Process/Read.hs:277:3) 2016-10-22 09:06:26.580468: [debug] Run process: /usr/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version @(System/Process/Read.hs:277:3) 2016-10-22 09:06:26.581494: [debug] Run process: /usr/bin/ghc-pkg --no-user-package-db list --global @(System/Process/Read.hs:277:3) 2016-10-22 09:06:26.642963: [debug] Process finished in 62 ms: /usr/bin/ghc --numeric-version @(System/Process/Read.hs:277:3) 2016-10-22 09:06:26.654798: [debug] Process finished in 74 ms: /usr/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version @(System/Process/Read.hs:277:3) 2016-10-22 09:06:26.695844: [debug] Process finished in 113 ms: /usr/bin/ghc-pkg --no-user-package-db list --global @(System/Process/Read.hs:277:3) 2016-10-22 09:06:26.696177: [debug] Resolving package entries @(Stack/Setup.hs:234:5) 2016-10-22 09:06:26.698075: [debug] Starting to execute command inside EnvConfig @(Stack/Runners.hs:166:18) 2016-10-22 09:06:26.698204: [debug] Parsing the cabal files of the local packages @(Stack/Build/Source.hs:282:5) 2016-10-22 09:06:26.698378: [debug] Running hpack on /home/danielv/private/local/hledger-orig/hledger-api/package.yaml @(Stack/Package.hs:1179:9) 2016-10-22 09:06:26.710208: [debug] hpack output unchanged in /home/danielv/private/local/hledger-orig/hledger-api/hledger-api.cabal @(Stack/Package.hs:1186:38) 2016-10-22 09:06:26.713096: [debug] Running hpack on /home/danielv/private/local/hledger-orig/hledger-lib/package.yaml @(Stack/Package.hs:1179:9) 2016-10-22 09:06:26.759234: [debug] hpack output unchanged in /home/danielv/private/local/hledger-orig/hledger-lib/hledger-lib.cabal @(Stack/Package.hs:1186:38) 2016-10-22 09:06:26.766953: [debug] Running hpack on /home/danielv/private/local/hledger-orig/hledger-ui/package.yaml @(Stack/Package.hs:1179:9) 2016-10-22 09:06:26.788369: [debug] hpack output unchanged in /home/danielv/private/local/hledger-orig/hledger-ui/hledger-ui.cabal @(Stack/Package.hs:1186:38) 2016-10-22 09:06:26.792431: [debug] Running hpack on /home/danielv/private/local/hledger-orig/hledger-web/package.yaml @(Stack/Package.hs:1179:9) 2016-10-22 09:06:26.900442: [debug] hpack output unchanged in /home/danielv/private/local/hledger-orig/hledger-web/hledger-web.cabal @(Stack/Package.hs:1186:38) 2016-10-22 09:06:26.909441: [debug] Running hpack on /home/danielv/private/local/hledger-orig/hledger/package.yaml @(Stack/Package.hs:1179:9) 2016-10-22 09:06:27.022540: [debug] hpack output unchanged in /home/danielv/private/local/hledger-orig/hledger/hledger.cabal @(Stack/Package.hs:1186:38) 2016-10-22 09:06:27.030883: [debug] Parsing the targets @(Stack/Build/Source.hs:219:5) 2016-10-22 09:06:27.090660: [debug] Exception ignored when attempting to load /home/danielv/private/local/hledger-orig/hledger-api/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/stack-build-cache: /home/danielv/private/local/hledger-orig/hledger-api/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/stack-build-cache: openBinaryFile: does not exist (No such file or directory) @(Data/Store/VersionTagged.hs:86:9) 2016-10-22 09:06:27.410295: [debug] Exception ignored when attempting to load /home/danielv/private/local/hledger-orig/hledger-ui/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/stack-build-cache: /home/danielv/private/local/hledger-orig/hledger-ui/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/stack-build-cache: openBinaryFile: does not exist (No such file or directory) @(Data/Store/VersionTagged.hs:86:9) 2016-10-22 09:06:27.430960: [debug] Exception ignored when attempting to load /home/danielv/private/local/hledger-orig/hledger-web/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/stack-build-cache: /home/danielv/private/local/hledger-orig/hledger-web/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/stack-build-cache: openBinaryFile: does not exist (No such file or directory) @(Data/Store/VersionTagged.hs:86:9) 2016-10-22 09:06:27.530936: [debug] Finding out which packages are already installed @(Stack/Build/Installed.hs:73:5) 2016-10-22 09:06:27.531473: [debug] Run process: /usr/bin/ghc-pkg --global --no-user-package-db dump --expand-pkgroot @(System/Process/Read.hs:277:3) 2016-10-22 09:06:27.672843: [debug] Process finished in 141 ms: /usr/bin/ghc-pkg --global --no-user-package-db dump --expand-pkgroot @(System/Process/Read.hs:277:3) 2016-10-22 09:06:27.690126: [debug] Ignoring package yaml due to wanting version 0.8.18.6 instead of 0.8.18.7 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.690327: [debug] Ignoring package x509 due to wanting version 1.6.3 instead of 1.6.4 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.690435: [debug] Ignoring package x509-validation due to wanting version 1.6.3 instead of 1.6.4 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.690641: [debug] Ignoring package text-binary due to wanting version 0.2.1 instead of 0.2.1.1 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.690748: [debug] Ignoring package streaming-commons due to wanting version 0.1.15.5 instead of 0.1.16 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.690889: [debug] Ignoring package stack due to wanting version 1.1.2 instead of 1.2.0 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.691015: [debug] Ignoring package QuickCheck due to wanting version 2.8.2 instead of 2.9.2 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.691186: [debug] Ignoring package optparse-applicative due to wanting version 0.12.1.0 instead of 0.13.0.0 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.691484: [debug] Ignoring package mono-traversable due to wanting version 1.0.0.1 instead of 1.0.1 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.691639: [debug] Ignoring package http-conduit due to wanting version 2.1.11 instead of 2.2.2.1 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.691749: [debug] Ignoring package http-client due to wanting version 0.4.31.1 instead of 0.5.3.2 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.691854: [debug] Ignoring package http-client-tls due to wanting version 0.2.4.1 instead of 0.3.3 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.691958: [debug] Ignoring package http-api-data due to wanting version 0.2.4 instead of 0.3.1 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.692069: [debug] Ignoring package hspec due to wanting version 2.2.3 instead of 2.2.4 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.692188: [debug] Ignoring package hspec-discover due to wanting version 2.2.3 instead of 2.2.4 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.692294: [debug] Ignoring package hspec-core due to wanting version 2.2.3 instead of 2.2.4 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.692395: [debug] Ignoring package hpack due to wanting version 0.14.1 instead of 0.15.0 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.692523: [debug] Ignoring package fast-logger due to wanting version 2.4.6 instead of 2.4.7 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.692777: [debug] Ignoring package cryptonite due to wanting version 0.19 instead of 0.20 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.692927: [debug] Ignoring package conduit due to wanting version 1.2.7 instead of 1.2.8 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.693043: [debug] Ignoring package conduit-extra due to wanting version 1.1.13.2 instead of 1.1.13.3 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.693167: [debug] Ignoring package attoparsec due to wanting version 0.13.0.2 instead of 0.13.1.0 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.693287: [debug] Ignoring package aeson due to wanting version 0.11.2.1 instead of 0.11.2.0 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.693502: [debug] Ignoring package extra due to wanting version 1.4.10 instead of 1.5 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.693788: [debug] Ignoring package time-locale-compat due to wanting version 0.1.1.3 instead of 0.1.1.1 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.694359: [debug] Ignoring package ieee754 due to wanting version 0.7.8 instead of 0.7.6 @(Stack/Build/Installed.hs:196:5) 2016-10-22 09:06:27.694893: [debug] Run process: /usr/bin/ghc-pkg --user --no-user-package-db --package-db /home/danielv/.stack/snapshots/x86_64-linux/lts-7.0/8.0.1/pkgdb dump --expand-pkgroot @(System/Process/Read.hs:277:3) 2016-10-22 09:06:27.791334: [debug] Process finished in 96 ms: /usr/bin/ghc-pkg --user --no-user-package-db --package-db /home/danielv/.stack/snapshots/x86_64-linux/lts-7.0/8.0.1/pkgdb dump --expand-pkgroot @(System/Process/Read.hs:277:3) 2016-10-22 09:06:27.792816: [debug] Run process: /usr/bin/ghc-pkg --user --no-user-package-db --package-db /home/danielv/private/local/hledger-orig/.stack-work/install/x86_64-linux/lts-7.0/8.0.1/pkgdb dump --expand-pkgroot @(System/Process/Read.hs:277:3) 2016-10-22 09:06:27.855749: [debug] Process finished in 62 ms: /usr/bin/ghc-pkg --user --no-user-package-db --package-db /home/danielv/private/local/hledger-orig/.stack-work/install/x86_64-linux/lts-7.0/8.0.1/pkgdb dump --expand-pkgroot @(System/Process/Read.hs:277:3) 2016-10-22 09:06:27.856652: [debug] Constructing the build plan @(Stack/Build/ConstructPlan.hs:157:5) 2016-10-22 09:06:27.864137: [debug] Checking if we are going to build multiple executables with the same name @(Stack/Build.hs:174:5) 2016-10-22 09:06:27.864445: [debug] Executing the build plan @(Stack/Build/Execute.hs:359:5) 2016-10-22 09:06:27.864816: [debug] Getting global package database location @(Stack/GhcPkg.hs:54:5) 2016-10-22 09:06:27.864928: [debug] Run process: /usr/bin/ghc-pkg --no-user-package-db list --global @(System/Process/Read.hs:277:3) 2016-10-22 09:06:27.935506: [debug] Process finished in 70 ms: /usr/bin/ghc-pkg --no-user-package-db list --global @(System/Process/Read.hs:277:3) 2016-10-22 09:06:27.938755: [debug] Encoding /home/danielv/private/local/hledger-orig/hledger/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/stack-build-cache @(Data/Store/VersionTagged.hs:51:5) 2016-10-22 09:06:27.952924: [debug] Finished writing /home/danielv/private/local/hledger-orig/hledger/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/stack-build-cache @(Data/Store/VersionTagged.hs:55:5) 2016-10-22 09:06:27.953095: [info] hledger-0.28: build @(Stack/Build/Execute.hs:740:23) 2016-10-22 09:06:27.953384: [debug] Run process: /home/danielv/.stack/setup-exe-cache/x86_64-linux/setup-Simple-Cabal-1.24.0.0-ghc-8.0.1 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.0.0 build lib:hledger exe:hledger --ghc-options " -ddump-hi -ddump-to-file" @(System/Process/Read.hs:277:3) 2016-10-22 09:06:28.065265: [info] Preprocessing library hledger-0.28... @(Stack/Build/Execute.hs:920:67) 2016-10-22 09:06:28.660017: [info] [ 4 of 22] Compiling Hledger.Cli.DocFiles ( Hledger/Cli/DocFiles.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/Hledger/Cli/DocFiles.o ) @(Stack/Build/Execute.hs:920:67) 2016-10-22 09:06:29.046456: [warn] @(Stack/Build/Execute.hs:920:67) 2016-10-22 09:06:29.047149: [warn] /home/danielv/private/local/hledger-orig/hledger/Hledger/Cli/DocFiles.hs:37:6: error: @(Stack/Build/Execute.hs:920:67) 2016-10-22 09:06:29.047364: [warn] * Exception when trying to run compile-time code: @(Stack/Build/Execute.hs:920:67) 2016-10-22 09:06:29.047516: [warn] /home/danielv/private/local/hledger-orig/hledger/doc/hledger.1: hGetContents: invalid argument (invalid byte sequence) @(Stack/Build/Execute.hs:920:67) 2016-10-22 09:06:29.047660: [warn] Code: (>>=) makeRelativeToProject "doc/hledger.1" embedStringFile @(Stack/Build/Execute.hs:920:67) 2016-10-22 09:06:29.047786: [warn] * In the untyped splice: @(Stack/Build/Execute.hs:920:67) 2016-10-22 09:06:29.047914: [warn] $(makeRelativeToProject "doc/hledger.1" >>= embedStringFile) @(Stack/Build/Execute.hs:920:67) 2016-10-22 09:06:29.179643: [debug] Encoding /home/danielv/private/local/hledger-orig/hledger/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/stack-build-cache @(Data/Store/VersionTagged.hs:51:5) 2016-10-22 09:06:29.203470: [debug] Finished writing /home/danielv/private/local/hledger-orig/hledger/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/stack-build-cache @(Data/Store/VersionTagged.hs:55:5)
-- While building package hledger-0.28 using:
/home/danielv/.stack/setup-exe-cache/x86_64-linux/setup-Simple-Cabal-1.24.0.0-ghc-8.0.1 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.0.0 build lib:hledger exe:hledger --ghc-options " -ddump-hi -ddump-to-file" Process exited with code: ExitFailure 1
On Fri, Oct 21, 2016 at 1:50 AM, Simon Michael notifications@github.com wrote:
Could you try stack --stack-yaml=stack-ghc8.yaml install hledger also. Perhaps GHC 8 will give a better error, revealing which tool it's coming from.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/simonmichael/hledger/issues/420#issuecomment-255249566, or mute the thread https://github.com/notifications/unsubscribe-auth/ABcrVqPZhsM2uflNv3Ht4wUeRhxKXro1ks5q1_AigaJpZM4KclR3 .
Those are great UX ideas for hledger, and I might have a wishlist issue open for it somewhere [nope, just a note].
For building hledger, those changes would need to be done in GHC and maybe other tools as well, right ?
PS what can you tell from the verbose log ? Is the error coming from GHC ?
@daniel-vainsencher did you ever figure out what was erroring ? Any idea what the resolution for this issue should be as far as hledger is concerned ?
This is easily reproduced with Docker. Do docker run -it fedora:28 bash
then run the install script from http://hledger.org/download.html
hledger-1.10: configure
hledger-1.10: build
-- While building custom Setup.hs for package hledger-1.10 using:
/root/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.3 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.2.0.1 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
Logs have been written to: /root/.stack/global-project/.stack-work/logs/hledger-1.10.log
Configuring hledger-1.10...
Preprocessing library for hledger-1.10..
Building library for hledger-1.10..
[ 1 of 30] Compiling Hledger.Cli.DocFiles ( Hledger/Cli/DocFiles.hs, .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.2.0.1/build/Hledger/Cli/DocFiles.o )
/tmp/stack69/hledger-1.10/Hledger/Cli/DocFiles.hs:38:6: error:
* Exception when trying to run compile-time code:
/tmp/stack69/hledger-1.10/embeddedfiles/hledger.1: hGetContents: invalid argument (invalid byte sequence)
Code: makeRelativeToProject "embeddedfiles/hledger.1"
>>= embedStringFile
* In the untyped splice:
$(makeRelativeToProject "embeddedfiles/hledger.1"
>>= embedStringFile)
|
38 | ($(makeRelativeToProject "embeddedfiles/hledger.1" >>= embedStringFile)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed to install hledger-1.10 hledger-lib-1.10
Thanks. This is a well known issue with haskell tools and applications built with GHC. Since hledger-install.sh is supposed to work around all known issues, I guess it should be setting LANG to something that can handle the hledger docs if it is unset. Like the Makefile does:
# GHC-compiled executables require a locale (and not just C) or they
# will die on encountering non-ascii data. Set LANG to something if not already set.
export LANG?=en_US.UTF-8
Maybe that syntax works in hledger-install.sh too ?
Do we also need to explain this in the b2, b3 and c steps on the download page ? On the downside, whenever we try to document every possible breakage the instructions become huge and unreadable.
@simonmichael I think it's best to fix this issue in the code itself, instead of trying to cover all possible ways stack/cabal could be called. The way to do this would be to simply hSetEncoding
on all files-to-be-embedded via a custom version of embedStringFile
- they should all be in UTF-8, right?
Instead of the file-embed
's version\
embedStringFile :: FilePath -> Q Exp
embedStringFile fp =
#if MIN_VERSION_template_haskell(2,7,0)
qAddDependentFile fp >>
#endif
(runIO $ P.readFile fp) >>= strToExp
replace the last line with
runIO $ do
h <- openFile fp ReadMode
hSetEncoding h utf8_bom
strToExp <$> hGetContents inputHandle
(Not tested, might open a PR after I get some desperately needed sleep...)
AFAIK, this should fix all problems compiling with LANG=POSIX or similar.
That sounds interesting. I have sometimes tried too hard to paper over tooling/ecosystem issues and regretted it; it can be more fragile and cost more than it's worth. Let us know if you try it.
Before: [danielv@dvflair hledger]$ stack install hledger hledger-ui hledger-web -j1 hledger-0.28: build Progress: 0/34 -- While building package hledger-0.28 using: /home/danielv/.stack/setup-exe-cache/x86_64-linux-ncurses6/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux-ncurses6/Cabal-1.22.5.0 build lib:hledger exe:hledger --ghc-options " -ddump-hi -ddump-to-file" Process exited with code: ExitFailure 1 Logs have been written to: /home/danielv/private/local/hledger/.stack-work/logs/hledger-0.28.log
After doing export LANG=en_US.utf8 Building works just fine. Some utf requiring data in the docs, I presume?
I guess there is a general good reason to depend on the platform locale, but is it ever useful to hledger users specifically? if so, please give error messages that clarify the problem.