I'm running into some errors when trying to run stack install --install-ghc --resolver lts-9 --keep-going to build master for a local dev environment. I am running Arch Linux. Here is a snippet of the error log:
-- While building custom Setup.hs for package clock-0.7.2 using:
/tmp/.stack/setup-exe-cache/x86_64-linux-tinfo6-nopie/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0 build --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: /tmp/hledger/.stack-work/logs/clock-0.7.2.log
Configuring clock-0.7.2...
Building clock-0.7.2...
Preprocessing library clock-0.7.2...
/tmp/stack10478/clock-0.7.2/Clock.hsc:44:0: warning: "hsc_alignment" redefined
/tmp/stack10478/clock-0.7.2/In file included from .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/System/Clock_hsc_make.c:1:0:
/tmp/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/template-hsc.h:88:0: note: this is the location of the previous definition
#define hsc_alignment(t...) \
/usr/bin/ld: .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/System/Clock_hsc_make.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
linking .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/System/Clock_hsc_make.o failed (exit code 1)
command was: /usr/bin/gcc .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/System/Clock_hsc_make.o .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/System/Clock_hsc_utils.o -o .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/System/Clock_hsc_make -fno-PIE -fno-stack-protector -L/tmp/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/base-4.9.1.0 -Wl,-R,/tmp/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/base-4.9.1.0 -L/tmp/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/integer-gmp-1.0.0.1 -Wl,-R,/tmp/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/integer-gmp-1.0.0.1 -lgmp -L/tmp/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/ghc-prim-0.5.0.0 -Wl,-R,/tmp/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/ghc-prim-0.5.0.0 -L/tmp/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/rts -Wl,-R,/tmp/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/rts -lm -lrt -ldl -lpthread
I'm quite unfamiliar with haskell. That said, instead of debugging this, I could see value to creating a Dockerfile or using nix-env to achive a reproducible local build setup without needing to modify system-level paths. Thoughts?
What do you mean when you say "modifying system level paths"?
Also, what happens if you run just "stack build"?
I was alluding to what ledger-install.sh might do to install things for the users' given system. /usr/bin or other install locations. These are pedestrian observations so I could be wrong here.
It appears to be the same error, I can post the entire log if helpful.
Hi @efx.. I'm not familiar with this particular error (or --keep-going) but it might be related to the recent major Haskell troubles on Arch. Two vaguely related links I found just now:
https://www.reddit.com/r/haskell/comments/6nleqc/arch_haskell
https://github.com/commercialhaskell/stack/issues/2712#issuecomment-254088034
I would make sure you're using an up to date stack (latest 1.5 at least).
We have a nix-env command on the download page, which works for some people (not all..). I think https://github.com/j3k0/docker-hledger is the latest on hledger & docker.
hledger-install.sh (there is no ledger-install.sh) doesn't modify paths. (It probably should do more to help users add ~/.local/bin to $PATH though).
PS I assume you get the same error from just running hledger-install.sh.
Awesome thanks for the help @adept and @simonmichael. It is stack 1.6.0.20171202 but I see another notice about being compiled with different dependencies. When I get some time later today, I'll try to put together a nix-env command or a dockerfile based on that other project. I do get the same errors when running ./hledger-install.sh.
Similar error encountered by other clock users: https://github.com/corsis/clock/issues/43
You are using ghc 8.0.2 which I would have expected to resolve this. But perhaps clock author knows more.
Spent some more time digging. Trying the various options mentioned on the arch wiki page and this issue: https://github.com/commercialhaskell/stack/issues/3268. Unfortunately have not gotten the stack install to work. The Stack FAQ doc explains the exact linking error I keep seeing. They mention using a container as well to create an isolated build environment. I'll probably pick it up again and go that route. The Plot Thickens :smile:
Prematurely closed, needs additional testing/workaround/download page advice for arch users building hledger.
A possible workaround for this issue: change -fno-PIE to -no-pie in the settings file for your GHC, as in this more recent comment at stack#2712. If you have this problem, please try this and and let us know.
I verified changing that setting to -no-pie causes the stack install to complete successfully. This was using stack Version 1.6.1, Git revision f25811329bbc40b0c21053a8160c56f923e1201b (5435 commits) x86_64 hpack-0.20.0
Thanks!
You can cleanly configure this by adding ghc-build: nopie to ~/.stack/config.yaml. Let me know if you want this included somewhere as documentation. See here for more discussion.
Thanks @efx. We may be ok for docs - download > arch linux points to this discussion. Unless you see a way to improve it.
Any further action required here ? We'd like "stack install" on Arch Linux to just work.
@simonmichael I'll test with a fresh install sometime today or tomorrow and document the steps.
Found another similar old issue.
I hadn't noticed the message before but installing stack from the official repositories reports:
You need to either 1) install latest stable ghc package from [extra] or 2) install libtinfo from AUR for the prebuilt binaries installed by stack to work.
I verified that from a clean install, when installing stack from the official repositories, you need to also install ncurses5-compat-libs. From within a docker container, cloning hledger and running stack install works up until Setup.hs in compiling hledger-lib. The error is similar to https://github.com/simonmichael/hledger/issues/420 and I saw another that says it is particular to containers too.
For now, recommending the ncurses lib install seems easiest but not necessarily ideal.
Thanks for the info. I've also linked this comment on the download page, and that's probably all we should do for Arch haskell at the moment.