Stack can't find -lncursesw - haskell

When I try compiling my Haskell program with Stack, I get the following error:
Building executable 'fractal' for fractal-0.1.0.0..
[1 of 2] Compiling Main ( app/Main.hs, .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.2.0.1/build/fractal/fractal-tmp/Main.o )
<command line>: can't load .so/.DLL for: /usr/lib/gcc/x86_64-unknown-linux-gnu/8.2.0/../../../../lib/libtinfo.so (-lncursesw: cannot open shared object file: No such file or directory)
-- While building custom Setup.hs for package fractal-0.1.0.0 using:
/home/lorxu/.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 lib:fractal exe:fractal --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
When I compile with GHC directly, it works fine, and libncursesw.so is present in /usr/lib. I'm on Void Linux. Any ideas where Stack is looking?

This looks like an issue with the bindist Stack has chosen for Void Linux - it normally guesses right, but it can cause issues on some distros. The tinfo6 variant tries to load libtinfo.so, since some distributions provide ncurses6 through that shared object file. You can try configuring the variant manually - you'll probably want standard. Stack will install a new GHC version if you do that, but it will change what shared object it tries to load for ncurses.
EDIT:
This was actually caused by an issue with GHC - if the distro links between the various ncurses files with a linker file, instead of an actual link, GHC won't follow it properly and instead complain that the file doesn't exist. The solution is to replace the linker file with a link to the target.

Related

realgcc.exe: error: \build\Graham-Hutton-Haskell-Excersizes\Graham-Hutton-Haskell-Excersizes-tmp\Main.o: No such file or directory

I am trying to set up a simple project so I can learn haskell, well, learn it from the ground up to get a better understanding of the theoretical concepts underpinning it. I do however seem to get this error when trying to build it using cabal.
I was trying to build it and was expecting the default main file for cabal to work.
My file system
module Main where
main :: IO ()
main = putStrLn "Hello, Haskell!"
I am using ghc version 8.10.7
I am running the following commands:
cabal init
cabal build
and then I get the error on the build command/
The full error:
Build profile: -w ghc-9.2.5 -O1
In order, the following will be built (use -v for more details):
Graham-Hutton-Haskell-Excersizes-0.1.0.0 (exe:Graham-Hutton-Haskell-Excersizes) (first run)
Preprocessing executable 'Graham-Hutton-Haskell-Excersizes' for Graham-Hutton-Haskell-Excersizes-0.1.0.0..
Building executable 'Graham-Hutton-Haskell-Excersizes' for Graham-Hutton-Haskell-Excersizes-0.1.0.0..
Linking C:\Users\beren\source\repos\Graham Hutton Haskell Excersizes\dist-newstyle\build\x86_64-windows\ghc-9.2.5\Graham-Hutton-Haskell-Excersizes-0.1.0.0\x\Graham-Hutton-Haskell-Excersizes\build\Graham-Hutton-Haskell-Excersizes\Graham-Hutton-Haskell-Excersizes.exe ...
realgcc.exe: error: C:\Users\beren\source\repos\Graham Hutton Haskell Excersizes\dist-newstyle\build\x86_64-windows\ghc-9.2.5\Graham-Hutton-Haskell-Excersizes-0.1.0.0\x\Graham-Hutton-Haskell-Excersizes\build\Graham-Hutton-Haskell-Excersizes\Graham-Hutton-Haskell-Excersizes-tmp\Main.o: No such file or directory
gcc.exe' failed in phase Linker'. (Exit code: 1)
edit:
https://github.com/bacdekker/haskell-excersizes
Well, after checking/installing/updating gcc it ended up working after I made a new project in a different directory.

Haskell Stack failing to install easyrender

I have GHC 8.0.2 installed on a Haskell stack, and I need a certain number of packages on it for my project, one being easyrender.
I install it using the following command, which works for all other package installations:
stack install easyrender
I get the following output:
easyrender-0.1.1.2: configure
-- While building package easyrender-0.1.1.2 using:
/home/nathan/.stack/programs/x86_64-linux/ghc-8.0.2/bin/ghc --make -odir /tmp/stack5987/easyrender-0.1.1.2/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup -hidir /tmp/stack5987/easyrender-0.1.1.2/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup -i -i. -clear-package-db -global-package-db -package-db=/home/nathan/.stack/snapshots/x86_64-linux/ghc-8.0.2/8.0.2/pkgdb -package-db=/home/nathan/.stack/global-project/.stack-work/install/x86_64-linux/ghc-8.0.2/8.0.2/pkgdb -hide-all-packages -package-id=base-4.9.1.0 -package-id=superdoc-0.1.2.5-9gGVGYAJpHrGct376cUN41 -optP-include -optP/tmp/stack5987/easyrender-0.1.1.2/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup/setup_macros.h /tmp/stack5987/easyrender-0.1.1.2/Setup.hs /home/nathan/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -main-is StackSetupShim.mainOverride -o /tmp/stack5987/easyrender-0.1.1.2/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup/setup -threaded
Process exited with code: ExitFailure 1
Logs have been written to: /home/nathan/.stack/global-project/.stack-work/logs/easyrender-0.1.1.2.log
[1 of 2] Compiling Main ( /tmp/stack5987/easyrender-0.1.1.2/Setup.hs, /tmp/stack5987/easyrender-0.1.1.2/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup/Main.o )
[2 of 2] Compiling StackSetupShim ( /home/nathan/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /tmp/stack5987/easyrender-0.1.1.2/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup/StackSetupShim.o )
/home/nathan/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs:3:1: error:
Failed to load interface for ‘Distribution.PackageDescription’
It is a member of the hidden package ‘Cabal-2.0.1.0’.
It is a member of the hidden package ‘Cabal-1.24.2.0’.
Use -v to see a list of the files searched for.
/home/nathan/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs:4:1: error:
Failed to load interface for ‘Distribution.Simple’
It is a member of the hidden package ‘Cabal-2.0.1.0’.
It is a member of the hidden package ‘Cabal-1.24.2.0’.
Use -v to see a list of the files searched for.
/home/nathan/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs:5:1: error:
Failed to load interface for ‘Distribution.Simple.Build’
It is a member of the hidden package ‘Cabal-2.0.1.0’.
It is a member of the hidden package ‘Cabal-1.24.2.0’.
Use -v to see a list of the files searched for.
/home/nathan/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs:6:1: error:
Failed to load interface for ‘Distribution.Simple.Setup’
It is a member of the hidden package ‘Cabal-2.0.1.0’.
It is a member of the hidden package ‘Cabal-1.24.2.0’.
Use -v to see a list of the files searched for.
/home/nathan/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs:7:1: error:
Failed to load interface for ‘Distribution.Simple.LocalBuildInfo’
It is a member of the hidden package ‘Cabal-2.0.1.0’.
It is a member of the hidden package ‘Cabal-1.24.2.0’.
Use -v to see a list of the files searched for.
Since Cabal seems to be a problem, I tried running stack install Cabal, but that doesn't do anything. The log file referenced just says the same thing as the output.
Ideas?
Nathan
This is a bug in the easyrender package description. Note that cabal-install's "new-build" encounters the same problem. See my comment on this stack issue: https://github.com/commercialhaskell/stack/issues/3560#issuecomment-344075524
Workaround is as described by Thomas's answer, and also in the issue at https://github.com/commercialhaskell/stack/issues/3560#issuecomment-343980627
The next stack release will emit a warning about this circumstance, which should reduce confusion in the future.
Unfortunately, easyrender does not have an issue tracker, it appears to only have a hackage page. I have emailed the author requesting that he fix this.
No such problems with cabal-install:
% cabal install easyrender
Resolving dependencies...
Downloading superdoc-0.1.2.5...
Configuring superdoc-0.1.2.5...
Building superdoc-0.1.2.5...
Installed superdoc-0.1.2.5
Downloading easyrender-0.1.1.2...
Configuring easyrender-0.1.1.2...
Building easyrender-0.1.1.2...
Installed easyrender-0.1.1.2
So I'm guessing this is an issue with stack handling non-simple builds in a different manner. Namely, cabal-install seems to assume Cabal is a dependency of the setup.hs while stack does not.
Just to check, I tried and could produce your same issue but adding Cabal to the setup-depends: line of the easyrender.cabal made it work fine.

Haskell Yesod problems

someone could help me?! I'm working in a Haskell Yesod site for college on a C9 workspace, I've already installed by command Yesod and update cabal, but when I try "stack build" command, this miserable error message appears:
$ stack build
aulahaskell-0.0.0: build (lib + exe)
Preprocessing library aulahaskell-0.0.0...
[ 7 of 13] Compiling Handler.Cliente ( src/Handler/Cliente.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/Handler/Cliente.o )
/home/ubuntu/workspace/web2017/src/Handler/Cliente.hs:10:1: error:
Failed to load interface for ‘Network.HTTP.Types.Status’
It is a member of the hidden package ‘http-types-0.9.1’.
Perhaps you need to add ‘http-types’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
-- While building package aulahaskell-0.0.0 using:
/home/ubuntu/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.2.0 build lib:aulahaskell exe:aulahaskell --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Seriously, I tried a bunch of things to fix it, but nothing is working =S
Just read the error message carefully:
Failed to load interface for ‘Network.HTTP.Types.Status’
It is a member of the hidden package ‘http-types-0.9.1’.
Perhaps you need to add ‘http-types’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
The line Perhaps you need to add ‘http-types’ to the build-depends in your .cabal file tells you what to do: You must add http-types to the build-depends: section of the library aulahaskell in your cabal file.
If this does not help, please post your cabal file.
How did you start the yesod project? It's recommended to do:
stack new my-yesod-project yesod-(your database here)
cd my-yesod-project
stack build
Thank you, guys! It was a problem on how I was starting the project, some files weren't installed on my workspace, so I delete the files, reinstall Yesod and cabal, create another new version after following this steps: https://www.yesodweb.com/page/quickstart

Using stack, ghc-mod and NixOS all together

I'm having some trouble getting all these tools to work together, and I would be interested to hear if someone has managed.
My main problem is the following: I have some external dependencies, which in my stack.yaml look like this:
nix:
enable: true
packages: [curl, postgresql94, zlib]
which are clearly provided by the nix system. When I run ghc-mod type Main.hs 39 19 on my current Main.hs I get the following:
EXCEPTION: types:
<command line>: can't load .so/.DLL for: /home/user/.stack/snapshots/x86_64-linux-nix/lts-7.15/8.0.1/lib/x86_64-linux-ghc-8.0.1/postgresql-libpq-0.9.2.0-IWEdPrPraPeE94ud73Ope3/libHSpostgresql-libpq-0.9.2.0-IWEdPrPraPeE94ud73Ope3-ghc8.0.1.so (libpq.so.5: cannot open shared object file: No such file or directory)
so it seems to be having trouble loading these external dependencies.
Any ideas how to proceed?

stack cannot build network - where's config.log?

I have a project to build with stack and it depends on network. When I do stack build, it says
[1 of 1] Compiling Main ( /tmp/stack23678/network-2.6.2.1/Setup.hs, /tmp/stack23678/network-2.6.2.1/.stack-work/dist/i386-linux/Cabal-1.22.5.0/setup/Main.o )
Linking /tmp/stack23678/network-2.6.2.1/.stack-work/dist/i386-linux/Cabal-1.22.5.0/setup/setup ...
Configuring network-2.6.2.1...
...
checking whether the C compiler works... no
configure: error: in `/tmp/stack23678/network-2.6.2.1':
configure: error: C compiler cannot create executables
See `config.log' for more details
Sure, I'd love to. But where is this config.log? Or how can I re-create it?
Just cabal install network (without stack) works fine but how could stack build use this?
In order to get better information here, you can make sure all generated files are saved by manually building network:
stack unpack network-2.6.2.1
cd network-2.6.2.1
stack init
stack build
I think C compiler cannot create executables means you don't have a working C compiler installed.
config.log is generated by the configure command, and I don't think stack saves that. stack does save other logging output in
~/.stack/global-project/.stack-work/logs/...
It's the same as what was emitted to your terminal, so it may not help.

Resources