Haskell Yesod problems - linux

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

Related

cabal build error `gcc` failed: connot find `#include`

I try to build qhull from hackage and get the error
fatal error: qhull_ra.h: No such file or directory
2 | #include "qhull_ra.h"
`gcc' failed in phase `C Compiler'. (Exit code: 1)
The file is in the Cdir and the relevant parts of the cabal file are
include-dirs: ./Cdir
C-sources: ./Cdir/libqhull_r.c
, ./Cdir/geom_r.c
, ...
The file qhull_ra.h is not listed as C-sources, because it is a header file.
I did not write the code and are not experienced with including C code into haskell packages. The failure occurs sometimes and sometimes not, but I cannot tell when. What is wrong? I want to upload the package (authorized by the author); what do I have to change to make it compile with cabal install?
I've noticed that cabal install is (since recently) much more strict than cabal build when looking for files. So, I believe here the problem is that your include files are not being picked up by cabal.
I think you can fix that by listing your header files in a includes: field. So at least:
include-dirs: Cdir
includes: qhull_ra.h
c-sources: Cdir/libqhull_r.c
, ...

How to build a project with an icon by `cabal build` or `stack build`

I want to build an executable with an icon. By googling it, I find the instruction here, but it only works by compiling a source file with ghc.
If I want to build a project with an executable by cabal build or stack build, how should I configure the .cabal or .yaml files such that cabal build or stack build can directly create an executable with an icon?
I've googled it for a while, but nothing useful.
I appreciate it if any tips are given.
According to #Willem Van Onsem's suggestion, the following is the solution:
for a stack project, add the following configure into the stack.yaml file
ghc-options:
"$targets": Icon.o
for a cabal project, add the following ghc-options into the .cabal file
ghc-options:
Icon.o

Stack: How to depend on a package during development?

There is a portion of my application that would be better if published to Hackage. I still don't know exactly what it will look like, so I need to make many changes to it while working on my application.
It's very easy to just create a module in my project and iterate there, but I would like to put it in its own project so it can have its own dependencies.
How can I have my project depend on this separate package during development? It should allow for quick iteration. Here's what I tried so far:
# stack.yaml
packages:
- '.'
- location: ../amqp-worker
# my-application.cabal
library
build-depends:
base >= 4.7 && < 5
, amqp-worker
But I get an error when I build:
$ stack build
cra-reporting-0.1.0.0: build
-- While building package cra-reporting-0.1.0.0 using:
/Users/seanhess/.stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.24.0.0-ghc-8.0.1 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.24.0.0 build lib:cra-reporting exe:cra-reporting-exe --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: /Users/seanhess/projects/simple/cra-reporting/.stack-work/logs/cra-reporting-0.1.0.0.log
Preprocessing library cra-reporting-0.1.0.0...
[8 of 8] Compiling Simple.DataX.Worker ( src/Simple/DataX/Worker.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.0.0/build/Simple/DataX/Worker.o )
/Users/seanhess/projects/simple/cra-reporting/src/Simple/DataX/Worker.hs:6:1: error:
Failed to load interface for ‘Network.Worker’
Perhaps you meant
Network.Socket (needs flag -package-key network-2.6.3.1)
Network.Wreq (from wreq-0.4.1.0)
Network.Socks5 (needs flag -package-key socks-0.5.5)
Use -v to see a list of the files searched for.
The external package seems to build fine if I run stack build from within its project folder.
Both projects are targeting lts-7.3
The above example should work. I attempted this again from scratch and it works fine. The error was due to some kind of build artifact.
If it happened again I would delete .stack-work in the sub-project and rebuild.

Trouble building a haskell module in IntelliJ

I get the following error message when I try to build a package in intellJIDEA using the haskell plugin. I think this message is an error with buildwrapper and not the plugin. However I am not sure how to synchronize buildwrapper in windows.
Error:(2, 8) ghc: Could not find module `Text.ParserCombinators.Parsec'
It is a member of the hidden package `parsec-3.1.5'.
Perhaps you need to add `parsec' to the build-depends in your .cabal file.
It is a member of the hidden package `parsec-3.1.3'.
Perhaps you need to add `parsec' to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
Any suggestions?
Manually edit the build-depends file to add the missing package.

Trying to install Image.Codec.DevIL under windows. Needs pthread and IL. Can't get IL to work

This is the output from cabal install codec-image-devil:
Resolving dependencies...
Configuring Codec-Image-DevIL-0.2.3...
cabal: Missing dependency on a foreign library:
* Missing C library: IL
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
cabal: Error: some packages failed to install:
Codec-Image-DevIL-0.2.3 failed during the configure step. The exception was:
ExitFailure 1
I tried --extra-include-dirs and --extra-lib-dirs. but they didn't work. so I edited the .cabal in Codec-Image-DevIL-0.2.3.tar.gz. I don't know if I'm even supposed to change that. but it worked for pthread.
I added these two lines:
include-dirs: C:\Users\Rumbold\Documents\libs\IL\include, C:\Users\Rumbold\Documents\libs\pthread\include, .
extra-lib-dirs: C:\Users\Rumbold\Documents\libs\IL\lib, C:\Users\Rumbold\Documents\libs\pthread\lib, .
They are indented so they are in the Library section. I don't know if I got the format for lists right, just something i stumbled upon while googling. The libs and `header files are all in the correct place, I think.
any clue how i can get it to work?
Edit_1:
I got it to work with --extra-include-dirs and --extra-lib-dirs, so I don't need to edit the cabal anymore. but IL still doesn't work. is there a way to find out which files it's looking for?
Wdit_2:
Alright it works. I had to rename DevIL.lib and DevIL.dll to libIL.lib and libIL.dll. (not sure if I had to do both, but that's what I did. also kept them under their old names)
Edit_3:
Getting lots of errors like:
"cabal\Codec-Image-DevIL-0.2.3\ghc-6.12.3/libHSCodec-Image-DevIL-0.2.3.a(DevIL.o):fake:(.text+0x2379):
undefined reference to `ilGetInteger#4'"

Resources