haskell stack exception missing dependencies - haskell

I want to add the bound library to my package dependencies;
The project is completely fresh initialized with stack new.
The entry in the cabal file looks like this:
executable DependendLambda-exe
hs-source-dirs: app
main-is: Main.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends: base
, DependendLambda
, bound
default-language: Haskell2010
I get the following error message:
While constructing the build plan, the following exceptions were encountered:
In the dependencies for DependendLambda-0.1.0.0:
bound must match -any, but the stack configuration has no specified
version (latest applicable is 1.0.7)
Recommended action:
try adding the following to your extra-deps in /home/MyProject/stack.yaml:
- bound-1.0.7
You may also want to try the 'stack solver' command
Plan construction failed.
Warning: build failed, but optimistically launching GHCi anyway
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Using main module: 1. Package `DependendLambda' component exe:DependendLambda-exe with main-is file: /home/MyProject/app/Main.hs
Configuring GHCi with the following packages: DependendLambda
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
<command line>: cannot satisfy -package bound
(use -v for more information)
When I add the dependency to extra-deps it is still failing:
While constructing the build plan, the following exceptions were encountered:
In the dependencies for bound-1.0.7:
binary-0.8.3.0 must match >=0.5 && <0.8 (latest applicable is 0.7.6.1)
comonad-5 must match >=3 && <5 (latest applicable is 4.3)
transformers-0.5.2.0 must match >=0.2 && <0.5 (latest applicable is 0.4.3.0)
needed due to DependendLambda-0.1.0.0 -> bound-1.0.7
Plan construction failed.
Warning: build failed, but optimistically launching GHCi anyway
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Using main module: 1. Package `DependendLambda' component
exe:DependendLambda-exe with main-is file: /home/MyProject/app/Main.hs
Configuring GHCi with the following packages: DependendLambda
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
<command line>: cannot satisfy -package bound-1.0.7
(use -v for more information)
The stack solver command didn't help either ... what am I missing?
Thanks for your help!

Related

Cannot build project with z3-haskell on windows 10

I want to build the haskell bindings for z3 in a Cabal project, the following is the minimum (faulty) example:
Using a project initialized by cabal init:
test/
- Main.hs
- Setup.hs
- CHANGELOG.md
- test.cabal
With modified test.cabal:
cabal-version: 3.0
name: z3-test
version: 0.1.0.0
extra-source-files: CHANGELOG.md
executable test
main-is: Main.hs
build-depends: base >=4.14 && <4.15
, z3 ^>=408.2
default-language: Haskell2010
Z3 binaries are located at C:\z3-4.8.5-x86-win.
Z3-bindings are installed:
cabal v1-install z3 --extra-lib-dirs=C:/z3-4.8.5-x64-win/bin --extra-include-dirs=C:/z3-4.8.5-x64-win/include -v3
All the requested packages are already installed:
z3-408.2
Use --reinstall if you want to reinstall anyway.
Now building the project using:
cabal v2-build --extra-lib-dirs=C:/z3-4.8.5-x64-win/bin --extra-include-dirs=C:/z3-4.8.5-x64-win/include -v3
Results in the error:
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
- z3-408.2 (lib) (requires build)
- z3-test-0.1.0.0 (exe:test) (first run)
Starting z3-408.2 (lib)
Failed to build z3-408.2. The failure occurred during the configure step.
Build log (
C:\cabal\logs\ghc-8.10.2\z3-408.2-1722a25655334afbca91ac935f14ff0d20ccf8c4.log
):
Configuring library for z3-408.2..
cabal.exe: Missing dependency on a foreign library:
* Missing (or bad) header file: z3.h
* Missing (or bad) C library: z3
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.If the
library file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
cabal.exe: Failed to build z3-408.2 (which is required by exe:test from
z3-test-0.1.0.0). See the build log above for details.
How can I build a project with the z3 bindings?
Note that:
GHC version = 8.10.2
Cabal version = 3.2.0.0
I can only use cabal
Using cabal install ... or cabal v2-install ... results in Cannot build .. z3 because none of the components are available to build:

Building project dependent on gtk2hs fails on lts-7.8 and later

Building project dependent on glib fails on lts-7.8 and later after Cabal becomes 1.24.1.0.
Steps to reproduce
Add glib to a project's .cabal file
build-depends: base
, gtktest
, glib
Run following commands
stack install gtk2hs-buildtools
stack build
Result
The following error occurred
...
[debug] Ignoring package Cabal due to wanting version 1.24.1.0 instead of 1.24.0.0
#(Stack\Build\Installed.hs:196:5)
...
-- While building package glib-0.13.4.1 using:
C:\Users\foo\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.1\bin\ghc.EXE --make -odir C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\.stack-work\dist\b7fec021\setup -hidir C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\.stack-work\dist\b7fec021\setup -i -i. -package=Cabal-1.24.0.0 -clear-package-db -global-package-db -package-db=C:\sr\snapshots\a78c6a89\pkgdb C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\Setup.hs -o C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\.stack-work\dist\b7fec021\setup\setup
Process exited with code: ExitFailure 1
Logs have been written to: C:\Users\foo\Documents\Files\Haskell\gtktest\.stack-work\logs\glib-0.13.4.1.log
[1 of 1] Compiling Main ( C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\Setup.hs, C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\.stack-work\dist\b7fec021\setup\Main.o )
C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\Setup.hs:8:29: error:
Couldn't match expected type ‘Distribution.Simple.UserHooks.UserHooks’
with actual type ‘Cabal-1.24.1.0:Distribution.Simple.UserHooks.UserHooks’
NB: Cabal-1.24.1.0:Distribution.Simple.UserHooks.UserHooks’
is defined in ‘Distribution.Simple.UserHooks’
in package ‘Cabal-1.24.1.0’
‘Distribution.Simple.UserHooks.UserHooks’
is defined in ‘Distribution.Simple.UserHooks’
in package ‘Cabal-1.24.0.0’
In the first argument of ‘defaultMainWithHooks’, namely
gtk2hsUserHooks’
In the expression: defaultMainWithHooks gtk2hsUserHooks
In an equation for ‘main’:
main = defaultMainWithHooks gtk2hsUserHooks
I thought that Cabal-1.24.0.0 in the ghc-8.0.1 global package was causing problems, and succeeded building it after installing Cabal-1.24.1.0 in ghc 's global package.
However, this method is difficult for beginners and I do not think the right solution. How is the correct way to solve it?
Stack version
Version 1.2.0, Git revision 123819b7d65df2ad7fe63fb5eb39a98536acb5f3 (4055 commits) x86_64 hpack-0.14.0

Haskell Stack's executable profiling and ghc options fails to build

I'm trying to debug performance problems in a Haskell project, but I can't get profiling to be compiled in so I can use it through +RTS -p command line arguments.
The options for GHC in my .cabal file are:
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Werror
Here's me attempting to build it:
stack build --executable-profiling --library-profiling --ghc-options="-fprof-auto -rtsopts"
Which results in:
While constructing the BuildPlan the following exceptions were encountered:
-- Failure when adding dependencies:
base: needed (>=2 && <5), not present in build plan (latest applicable is 4.9.0.0)
mtl: needed (>=2.1 && <2.3), couldn't resolve its dependencies
random: needed (-any), couldn't resolve its dependencies
transformers: needed (>=0.3 && <0.6), couldn't resolve its dependencies
transformers-compat: needed (>=0.4 && <0.6), couldn't resolve its dependencies
needed for package: MonadRandom-0.4.2.3
-- Failure when adding dependencies:
base: needed (>=4 && <5), not present in build plan (latest applicable is 4.9.0.0)
stm: needed (>=2.0 && <2.5), couldn't resolve its dependencies
transformers: needed (>=0.2 && <0.6), couldn't resolve its dependencies
needed for package: StateVar-1.1.0.4
<snipped large log>
Even trying with just stack build --executable-profiling results in the same error.
For reference, my library dependencies are:
build-depends: base >= 4.7 && < 5
, aeson
, servant
, servant-server
, wai
, warp
, either
, bytestring
, transformers
, postgresql-simple
, amazonka
, amazonka-sqs
, lens
, text
, time
, resource-pool
How can I resolve this so I can compile my project with stack and have profiling built in for use with +RTS -p?
What does "stack exec -- which ghc" say? If your ghc is installed globally, it could be that it lacks profiling libraries. If so, "stack setup --no-system-ghc" + "stack build --no-system-ghc"
What is your stack.yaml configuration? If you've set a resolver of "ghc-*", it won't work unless you specify the versions of all your dependencies in "extra-deps". Usually you'll want to use a stackage snapshot - https://www.stackage.org/

Dependency issues running "cabal test" for Haskell

I'm running my first "cabal test" for Haskell, but I get the error:
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
Configuring sample-0.1.0.0...
cabal: At least the following dependencies are missing:
base ==4.7.*
sampel.cabal:
-- Initial sample.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: sample
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.10
executable SampleTest
main-is: SampleTest.hs
build-depends: base >= 4.7 && <4.8, HUnit >=1.2 && <1.3
hs-source-dirs: test, src
default-language: Haskell2010
Any help appreciated.
Versions of GHC come bundled with versions of base. GHC 7.10.2 uses base 4.8.1.0.
Your cabal must be using a slightly out of date template....
You should either change the range of acceptable base version (as you did in your comment above), or use a different version of GHC.

Cabal repl won't run, "can't load .so/.DLL for: ..."

I am trying to get a project running that uses conduit and conduit-extra. This is the main module:
import Data.Conduit
main = do
putStrLn "Done"
The cabal file requires base, conduit and conduit-extra:
...
build-depends: base >=4.8 && <4.9,
conduit >=1.2.5 && <1.3,
conduit-extra >= 1.1.9.1 && <1.2
...
Yet when I run cabal repl, this happens:
Johns-iMac:The-Project john$ cabal repl
Preprocessing executable 'The-Project' for The-Project-0.1.0.0...
GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help
<command line>: can't load .so/.DLL for: /Library/Haskell/ghc-7.10.2-x86_64/lib/exceptions-0.8.0.2/libHSexceptions-0.8.0.2-8GsEeHgaIks3pVGk6GaELJ-ghc7.10.2.dylib (dlopen(/Library/Haskell/ghc-7.10.2-x86_64/lib/exceptions-0.8.0.2/libHSexceptions-0.8.0.2-8GsEeHgaIks3pVGk6GaELJ-ghc7.10.2.dylib, 5): Library not loaded: #rpath/libHStransformers-compat-0.4.0.4-DCQioW2d4vYEa3T0AmFBPv-ghc7.10.2.dylib
Referenced from: /Library/Haskell/ghc-7.10.2-x86_64/lib/exceptions-0.8.0.2/libHSexceptions-0.8.0.2-8GsEeHgaIks3pVGk6GaELJ-ghc7.10.2.dylib
Reason: image not found)
I just completely reinstalled the Haskell Platform, and it's all sandboxed, so there shouldn't be any problems with competing dependencies.
What is happening, and how do I fix it?
UPDATE:
I deleted the sandbox (cabal.sandbox.config, .cabal-sandbox), and reinstalled the dependencies:
cabal sandbox init
cabal install --only-dependencies
cabal repl
We now have a new but very similar error:
Johns-iMac:The-Project john$ cabal repl
Preprocessing executable 'The-Project' for The-Project-0.1.0.0...
GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help
<command line>: can't load .so/.DLL for: /Library/Haskell/ghc-7.10.2-x86_64/lib/hashable-1.2.3.3/libHShashable-1.2.3.3-2GTZqecVp8NJZrNuKzGxfy-ghc7.10.2.dylib (dlopen(/Library/Haskell/ghc-7.10.2-x86_64/lib/hashable-1.2.3.3/libHShashable-1.2.3.3-2GTZqecVp8NJZrNuKzGxfy-ghc7.10.2.dylib, 5): Library not loaded: #rpath/libHStext-1.2.1.3-1l1AN4I48k37RaQ6fm6CEh-ghc7.10.2.dylib
Referenced from: /Library/Haskell/ghc-7.10.2-x86_64/lib/hashable-1.2.3.3/libHShashable-1.2.3.3-2GTZqecVp8NJZrNuKzGxfy-ghc7.10.2.dylib
Reason: image not found)
Given that this report refers to a problem loading hashable, and the Github report refers to a problem loading exceptions, both of which are packages provided by the platform and not GHC, I have a feeling there's a problem with the platform installer. Can you try again with either GHC for Mac OS X or stack and see if it resolves the issue?
Note that, if you go the stack route, you'll want to run stack init && stack build --install-ghc && stack ghci in your project. In either case: you'll probably be safer if you completely remove the platform install first.

Resources