Haskell Stack build error - ghc.exe: could not execute - haskell

Getting following error when trying to stack build snowdrift on Windows:
Linking .stack-work\dist\i386-windows\Cabal-1.18.1.5\build\SnowdriftEmailDaemon\SnowdriftEmailDaemon.exe ...
ghc.exe: could not execute: C:\Users\Razvan\AppData\Local\Programs\stack\i386-windows\ghc-7.8.4\lib/../mingw/bin/gcc.exe
Completed all 6 actions.
-- While building package Snowdrift-0.1.4 using:
C:\\Users\\Razvan\\AppData\\Local\\Programs\\stack\\i386-windows\\ghc-7.8.4\\bin\\runhaskell.exe -package=Cabal-1.18.1.5 -clear-package-db -global-package-db -package-db=C:\Users\Razvan\AppData\Roaming\stack\snapshots\i386-windows\lts-2.13\7.8.4\pkgdb\ C:\Users\Razvan\AppData\Local\Temp\stack124196\Setup.hs --builddir=.stack-work\dist\i386-windows\Cabal-1.18.1.5\ build
Process exited with code: ExitFailure 1
My question is how to obtain more information on this error as it is quite vague. Looking under .\.stack-work\logs I can't find any snowdrift related log. It is almost like setting the stack verbosity level to debug does not affect ghc/gcc verbosity level or maybe extra error information is just not there.
More information on the issue here.

Related

How do I fix the following error when using "stack setup"?

So I am trying to make a Haskell project using stack but when I use the "stack setup" command I get the following error:
The GHC located at /Users/......./.ghcup/tmp/ghcup-ghc-9.2.4/ghc failed to compile a sanity check. Please see:
http://docs.haskellstack.org/en/stable/install_and_upgrade/
for more information. Exception was:
Received ExitFailure 1 when running
Raw command: /Users/....../.ghcup/tmp/ghcup-ghc-9.2.4/ghc /private/var/folders/jr/fkn85rwj2l78jxbdpgdz7j840000gn/T/stack-sanity-check-23bb16b9890cb72e/Main.hs -no-user-package-db
Run from: /private/var/folders/jr/fkn85rwj2l78jxbdpgdz7j840000gn/T/stack-sanity-check-23bb16b9890cb72e/
Standard output:
Loaded package environment from /Users/......../.ghc/aarch64-darwin-9.2.4/environments/default
Standard error:
<command line>: cannot satisfy -package-id rts
(use -v for more information)
I have tried a few ways but it doesn't seem to help. Anyone have suggestions? Thanks in advance.
I tried updating stack and reinstalling it but it did not help and the error still persists.

“Unable to load package `regex-posix` … unknown symbol ‘regerror’”

For a new project, I have been trying to build the threepenny-gui package, something which I have done many times in the past without any trouble. This time however, I ran into an unusual error message:
> stack build
threepenny-gui > configure
threepenny-gui > Configuring threepenny-gui-0.9.0.0...
threepenny-gui > build
threepenny-gui > Preprocessing library for threepenny-gui-0.9.0.0..
threepenny-gui > Building library for threepenny-gui-0.9.0.0..
threepenny-gui > [ 1 of 29] Compiling Foreign.JavaScript.Include
threepenny-gui > [ 2 of 29] Compiling Foreign.JavaScript.Resources
threepenny-gui > ghc.exe: unable to load package `regex-posix-0.96.0.0'
threepenny-gui > ghc.exe: | C:\sr\snapshots\14724cfd\lib\x86_64-windows-ghc-8.8.4\regex-posix-0.96.0.0-11M5Q2Uki3ACYikP2WXOuq\HSregex-posix-0.96.0.0-11M5Q2Uki3ACYikP2WXOuq.o: unknown symbol `regerror'
-- While building package threepenny-gui-0.9.0.0 using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_3.0.1.0_ghc-8.8.4.exe --builddir=.stack-work\dist\29cc6475 build --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
Progress 1/2
Now, a quick Google shows that this error message has been seen before — in 2010, after which it was fixed with a GHC update. I tried changing GHC versions (that output above was with GHC 8.8.4), but it didn’t work with 8.8.3 or 8.8.2 either. I also tried deleting regex-posix¹ and reinstalling it again, but that didn’t work either. At this point, I must confess that this error has completely stumped me; does anyone else have any idea what might be causing it, and if so, how can I fix it?
¹ Specifically, I removed C:\sr\snapshots\14724cfd\lib\x86_64-windows-ghc-8.8.4\regex-posix-0.96.0.0-11M5Q2Uki3ACYikP2WXOuq and C:\sr\snapshots\14724cfd\pkgdb\regex-posix-0.96.0.0-11M5Q2Uki3ACYikP2WXOuq.conf, and did ghc-pkg unregister regex-posix.
This turned out to be a problem in regex-posix rather than threepenny-gui. This issue could be fixed by enabling the Cabal flag _regex-posix-clib. To set it, I first needed to unregister the previous version of regex-posix:
> stack --resolver lts-16.23 exec -- ghc-pkg unregister regex-posix-0.96.0.0 --force
I then needed to rebuild it with the correct flag:
> stack build regex-posix-0.96.0.0 --flag regex-posix:_regex-posix-clib --resolver lts-16.23
After which stack build threepenny-gui --resolver lts-16.23 was successful. (For some reason, I needed to specify the resolver explicitly in these commands.)

Using Build-Tools (Alex) with Stack and GHCjs

I depend on a package that needs alex to build, i also need ghcjs.
When i try to run stack ghci:
language-java-0.2.8: configure (lib)
Error:
-- While building package language-java-0.2.8 using:
<long command>
Process exited with code: ExitFailure 1
Logs have been written to: /Users/LeanderK/Documents/Haskell/exemplator-java_parser/.stack-work/logs/language-java-0.2.8.log
Configuring language-java-0.2.8...
Cabal-simple_mPHDZzAJ_1.24.2.0_ghcjs-0.2.1.9007019_ghc-8.0.1: The program
'alex' version >=3.1.3 is required but it could not be found.
Warning: Build failed, but optimistically launching GHCi anyway
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: exemplator-client
Using main module: 1. Package `exemplator-client' component exe:exemplator-client-exe with main-is file: ..../app/Main.hs
Progress: 1/2<command line>: cannot satisfy -package language-java-0.2.8
(use -v for more information)
I've tried: stack build alex (just returns, don't have any output. Might work), stack install alex (doesn't work).
Output of stack install alex
Couldn't find executable alex in directory .../.stack/snapshots/x86_64-osx/lts-7.19/ghcjs-0.2.1.9007019_ghc-8.0.1/bin/
For reference: This is the cabal file of the dependency, unfortunately only found on github. This is my stack and my cabal file. There is also a reddit discussion that didn't go anywhere.

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.

GHC could not execute gcc.exe in Yesod Installation

I followed "Yesod quick start guide" to install Yesod in Windows 10.
But, when I issued the stack build command, it failed.
Environment
Windows 10 (64bits)
stack-0.1.5 (for Windows10 64bits)
No Haskell Platform
I executed these commands
stack new my-project yesod-sqlite && cd my-project
stack install yesod-bin cabal-install --install-ghc
stack setup
stack build <--- the error occured
In 'stack build' command, the package installations were done. But, when it build the project, the error occured.
Command Prompt
>stack build
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
my-project-0.0.0: build
Preprocessing library my-project-0.0.0...
In-place registering my-project-0.0.0...
Preprocessing executable 'my-project' for my-project-0.0.0...
Linking .stack-work\dist\x86_64-windows\Cabal-1.22.4.0\build\my-project\my-project.exe ...
ghc.exe: could not execute: C:\Users\xxxxx\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.2\lib/../mingw/bin/gcc.exe
-- While building package my-project-0.0.0 using:
C:\Users\xxxxx\AppData\Roaming\local\bin\stack-0.1.5.0\setup-exe-cache\setup-Simple-Cabal-1.22.4.0-x86_64-windows-ghc-7.10.2.exe --builddir=.stack-work\dist\x86_64-windows\Cabal-1.22.4.0\ build lib:my-project exe:my-project --ghc-options -ddump-hi -ddump-to-file
Process exited with code: ExitFailure 1
This is caused by the argument length limit on Windows. Starting in GHC 7.10.3, GHC will support response files for sending linker arguments in order to bypass this limitation. In the meanwhile, a workaround is to manually make the path to your stack root shorter by setting the STACK_ROOT environment variable.
For more information, see https://www.fpcomplete.com/blog/2015/08/stack-ghc-windows

Resources