cabal sandbox dependencies not found - haskell

I have a problem when I work with cabal sandbox, I created a sandbox for a 'hello world' application but when I try to run cabal install --only-dependencies I get the following error:
$ cabal install --only-dependencies
Resolving dependencies... cabal: Could not resolve dependencies:
trying: haskeline-0.7.2.1/installed-dad... (user goal) next goal:
helloworld (user goal) rejecting: helloworld-0.1.0.0 (conflict:
haskeline => base==4.7.0.2/installed-918..., helloworld => base>=4.8
&& <4.9) Dependency tree exhaustively searched.
Note: when using a sandbox, all packages are required to have
consistent dependencies. Try reinstalling/unregistering the offending
packages or recreating the sandbox.
I want to mention that if I try to run on this sandbox cabal repl I get the error.
$ cabal repl
Package has never been configured. Configuring with default flags. If
this fails, please run configure manually. Resolving dependencies...
Configuring helloworld-0.1.0.0... cabal: At least the following
dependencies are missing: base ==4.8.*
If I run cabal repl outside of sandbox everything is working ok.
If any of you have an idea pls share with me :),
thanks
sorin

It looks like your version constraints want you to use GHC 7.10- which bundles base version 4.8- while you're using GHC 7.8 and base 4.7. You could:
Modify the cabal file and its base version bounds
Switch to a different version of GHC
Try building with stack, which will automatically detect those kinds of things during stack init and then offer to install the appropriate GHC for you.

Related

cabal fails to find a library built and installed with cabal install --lib (linux)

I am building a Haskell library with Cabal,
and want to use this library in some other Cabal projects.
The problem is that after installing the library (with Cabal),
my library is not available to the other Cabal projects.
Neither ghc-pkg list nor cabal list shows my library
(and also does not show packages that my library depends on but
was downloaded by cabal as part of the build of my library).
How do I make cabal find my library when building the dependent projects?
I am using Linux, but the same problem has been reported for
Windows.
My setup:
Linux (Debian 11.5)
Haskell installed by ghcup:
ghc 8.0.2
cabal 3.6.2
(My library and the other projects need this version of ghc.)
My library builds and installs without problems using
$ cabal build
$ cabal install --lib
But ghc-pkg list and cabal list --installed both show only the
"predefined" libraries that was installed before the build.
These are found in ~/.ghcup/ghc/8.0.2/lib/ghc-8.0.2/package.conf.d/.
My library, and the libraries that it depends on, are installed in
~/.cabal/store/ghc-8.0.2/package.db/. But cabal doesn't find them
when building my other dependent projects.
I have tried different options for building, all with the same
result of
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: <PRJ-USING-LIB> (user goal)
[__1] unknown package: wilde (dependency of <PRJ-USING-LIB>)
[__1] fail (backjumping, conflict set: <PRJ-USING-LIB>, <MY-LIB>)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: <PRJ-USING-LIB>, <MY-LIB>
The options I tried are:
cabal build --global
cabal build --user
cabal build --package-db=~/.cabal/store/ghc-8.0.2/package.db
Interestingly, when adding ghc-options: -L<PATH-TO-MY-LIB-SRC> to the
dependent projects cabal file, cabal build says that my library is hidden:
...
Warning: Instead of 'ghc-options: -L<PATH-TO-MY-LIB-SRC>' use
'extra-lib-dirs: <PATH-TO-MY-LIB-SRC>'
...
app/Main.hs:3:1: error:
Failed to load interface for ‘<MODULE-IN-MY-LIB>’
It is a member of the hidden package ‘<MY-LIB>-0.5’.
Perhaps you need to add ‘<MY-LIB>’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
But trying to ghc-pkg expose <MY-LIB>, it says that
it cannot find .

cabal: Encountered missing dependencies:

I am trying to install a Haskell program (itself a compiler for another programming language) from the Github repository.
The Elm compiler is itself a Haskell program and I would like to compile it from source:
$ cabal configure
Resolving dependencies...
Warning: solver failed to find a solution:
Could not resolve dependencies:
trying: elm-0.19.1 (user goal)
next goal: zip-archive (dependency of elm-0.19.1)
Dependency tree exhaustively searched.
Trying configure anyway.
Configuring elm-0.19.1...
cabal: Encountered missing dependencies:
SHA -any,
ansi-terminal ==0.8.*,
ansi-wl-pprint >=0.6.8 && <0.7,
containers >=0.5.8.2 && <0.6,
If I try to use a different command the computer searches for a different version of the Elm programming language.
$ cabal install elm
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: Elm-0.13 (user goal)
trying: base-4.12.0.0/installed-4.1... (dependency of Elm-0.13)
next goal: transformers (dependency of Elm-0.13)
rejecting: transformers-0.5.6.2/installed-0.5..., transformers-0.6.0.2,
transformers-0.5.6.2, transformers-0.5.5.2, transformers-0.5.5.0,
transformers-0.5.4.0, transformers-0.5.2.0, transformers-0.5.1.0,
transformers-0.5.0.1, transformers-0.5.0.0 (conflict: Elm => transformers>=0.2
&& <0.5)
rejecting: transformers-0.4.3.0, transformers-0.4.2.0 (conflict:
I already have Elm installed globally and I would like to install a local copy that I cloned from Github. The cabal documentation doesn't say much.
Helpful information:
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5
$ cabal --version
cabal-install version 1.24.0.2
compiled using version 1.24.2.0 of the Cabal library
Trying different things possibly at risk:
$ cabal install --only-dependencies
Resolving dependencies...
internal error: could not construct a valid install plan.
The proposed (invalid) plan contained the following problems:
Package time is required by several packages, but they require inconsistent
versions:
package zip-archive-0.3.3 requires time-1.10
package snap-server-1.1.2.0 requires time-1.10
package snap-core-1.0.4.2 requires time-1.10
package io-streams-1.5.2.1 requires time-1.10
package http-client-0.6.4.1 requires time-1.10
package elm-0.19.1 requires time-1.10
package directory-1.3.6.2 requires time-1.10
package cookie-0.4.5 requires time-1.10
package HTTP-4000.3.16 requires time-1.10
package unix-2.7.2.2 requires time-1.8.0.2
Proposed plan:
Configured HTTP-4000.3.16 (.fake.HTTP-4000.3.16)
Configured SHA-1.6.4.4 (.fake.SHA-1.6.4.4)
Configured ansi-terminal-0.8.2 (.fake.ansi-terminal-0.8.2)
Configured ansi-wl-pprint-0.6.8.2 (.fake.ansi-wl-pprint-0.6.8.2)
Configured asn1-encoding-0.9.6 (.fake.asn1-encoding-0.9.6)
Configured asn1-parse-0.9.5 (.fake.asn1-parse-0.9.5)
Configured asn1-types-0.3.4 (.fake.asn1-types-0.3.4)
Your cabal is very old, and I strongly recommend you upgrade.
That said... with cabal-1, the invocation is simply
cabal install
with no elm at the end. Run it from within the directory you cloned from github that has a file named elm.cabal or similar -- it will automatically look for a file with extension .cabal and install the package described inside. cabal install will also take care of installing the missing dependencies.
With modern cabal, and assuming the executable named in the .cabal file is called elm, I would use
cabal run elm -- --args --for --elm --compiler
to run the compiler during testing, and then
cabal install --exe
when you are satisfied with your changes and want to make the executable available more widely.

yesod with stackage is failing to install due to dependency problems

I tried to set up a yesod project as follows:
mkdir sample_blog
curl -o cabal.config www.stackage.org/nightly/cabal.config
cabal install alex happy yesod-bin
However, I got the following error:
Resolving dependencies...
cabal: Could not resolve dependencies:
next goal: Cabal (user goal)
rejecting: Cabal-1.18.1.4/installed-d6c... (global constraint requires
==1.18.1.3)
trying: Cabal-1.18.1.3/installed-476...
trying: yesod-bin-1.4.2 (user goal)
next goal: ghc (dependency of yesod-bin-1.4.2)
rejecting: ghc-7.8.3/installed-1d5... (conflict:
Cabal==1.18.1.3/installed-476..., ghc => Cabal==1.18.1.4/installed-d6c...)
Dependency tree exhaustively searched.
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
I've install GHC and cabal-install using homebrew.
Versions:
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.3
$ cabal --version
cabal-install version 1.20.0.4
using version 1.20.0.3 of the Cabal library
It appears that homebrew has patched the standard GHC installation, as it's shipping with a different version of the Cabal library than the official GHC. I don't know why that is occurring. A quick workaround would be to remove the Cabal line from your cabal.config. Can you open up an issue against Stackage about this? I'd like to get to the bottom of why this is occurring.

QuickCheck unresolved dependency while installing Haskell Platform from source

I'm trying to install Haskell Platform 2014.2.0.0, but running platform.sh script gives me dependency error, which I am not able to resolve. Error message is:
cabal: Could not resolve dependencies:
trying: alex-3.1.3 (user goal)
next goal: QuickCheck (dependency of alex-3.1.3)
rejecting: QuickCheck-2.7.6 (global constraint requires ==2.6)
I tried to ghc-pkg unregister QuickCheck-2.7.6 and cabal install QuickCheck-2.6, but it still fails due to same reason. Besides that I tried to install alex-3.1.3 manually and when that failed too I cleared all packages from my home directory.
I have Haskell Platform 2013 installed but I also installed Cabal 1.18 manually.
Any ideas how I can resolve this?
I've searched a web and StackOverflow a bit just to find out that HP installation script is broken on many systems. Eventually I gave up on installing whole HP and went for newest binary distribution of GHC and Cabal which seems to be the simplest way of getting most recent Haskell for my Linux.

Cabal configure in a sandbox complains "At least the following dependencies are missing" on installed packages

I have a project, it's inside a sandbox, I introduced a test-suite in my cabal file and it build-depends on hunit ==1.2.*. The problem is when I try to configure:
$ cabal configure --enable-tests
Resolving dependencies...
Configuring MyProject-0.1.0.0...
cabal: At least the following dependencies are missing:
hunit ==1.2.*
A few more attempts to get it to come around:
$ cabal install --dependencies-only
Resolving dependencies...
All the requested packages are already installed:
Use --reinstall if you want to reinstall anyway.
&
$ cabal install hunit
Resolving dependencies...
All the requested packages are already installed:
HUnit-1.2.5.2
Use --reinstall if you want to reinstall anyway.
&
$ cabal install --enable-tests
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: MyProject-0.1.0.0 (user goal)
rejecting: MyProject-0.1.0.0:!test (global constraint requires opposite flag
selection)
trying: MyProject-0.1.0.0:*test
next goal: hunit (dependency of MyProject-0.1.0.0:*test)
fail (unknown package: hunit)
Dependency tree exhaustively searched.
--reinstalling did nothing.
I even played with the --user and --global flags, even tho I'm using cabal and not runhaskell, it doesn't help it.
I also tried to delete & re-init the sandbox.
I tried just deleteing the sandbox too, and it still gave me the same error.
ghc-pkg check finds nothing wrong.
What could it be?
By the way a part of me is suspicious that cabal ignores that my project is in a sandbox, since it didn't bother to install some packages that were already on my machine; it does so on my Windows (this is on Ubuntu). Is it possible to get that checked?
Ubuntu 14.04.1 LTS
GHC version: 7.6.3
cabal-install version: 1.20.0.3
Cabal library version: 1.20.0.2
Also tried now with cabal-install 1.16.0.2 without success.
Package names are case sensitive in Cabal/Hackage, the correct package name is HUnit. Change the line in your cabal file containing:
hunit ==1.2.*
To
HUnit ==1.2.*

Resources