Stack insists on building Cabal package - haskell

I am working on a Haskell project using Stack.
Recently, we started using the lens package which requires the Cabal package as a dependency, but we switched to lens-simple because building the Cabal package was too resource intensive for some older machines that we tested building the project on.
However, despite the fact that neither lens-simple nor any of our other packages have a dependency on the Cabal package, Stack continues to try and build it.
Is there anyway to get Stack to stop this? It makes the build process very long on most machines and impossible on weaker machines.
A list of the project's dependencies:
HUnit 1.6.0.0
QuickCheck 2.12.6.1
ansi-terminal 0.8.2
array 0.5.3.0
base 4.12.0.0
binary 0.8.6.0
bytestring 0.10.8.2
call-stack 0.1.0
clock 0.7.2
colour 2.3.4
containers 0.6.0.1
deepseq 1.4.4.0
directory 1.3.3.0
erf 2.0.0.0
filepath 1.4.2.1
ghc-boot-th 8.6.3
ghc-prim 0.5.3
hspec 2.6.1
hspec-core 2.6.1
hspec-discover 2.6.1
hspec-expectations 0.8.2
integer-gmp 1.0.2.0
lens-family 1.2.3
lens-family-core 1.2.3
lens-family-th 0.5.0.2
lens-simple 0.1.0.9
mtl 2.2.2
ncurses 0.2.16
netflak 0.1.0.0
pretty 1.1.3.6
primitive 0.6.4.0
quickcheck-io 0.2.0
random 1.1
rts 1.0
setenv 0.1.1.3
stm 2.5.0.0
template-haskell 2.14.0.0
text 1.2.3.1
tf-random 0.5
time 1.8.0.2
transformers 0.5.5.0
unbounded-delays 0.1.1.0
unix 2.7.2.2

My guess is that one of your dependencies using a custom setup stanza, where Stack needs to build the Setup.hs file against the Cabal library, thus the implicit dependency. We have a bit of a discussion going already for Stackage as to whether we should provide up to date versions of the Cabal library as we do today—and risk forcing people to build a heavy dependency—versus sticking to the version of Cabal that ships with GHC.
Anyway, you can work around this with a slightly convoluted approach where you create a custom snapshot that drops the Cabal library. It would look something like this:
# stack.yaml: point to the custom snapshot
resolver: snapshot.yaml
# snapshot.yaml: use the original snapshot and add a drop-packages
resolver: nightly-2019-03-17
name: drop-cabal
drop-packages:
- Cabal

Related

Trouble building yesod/amazonka dependencies in a Haskell Stack project

I'm trying to use the excellent AWS SDK amazonka in the backend portion of an API built using the equally excellent web framework yesod, but I am having great difficulty getting the dependencies for these two libraries to work together.
I started the scaffolded yesod project with
stack new my-project yesod-mongo
which populated my cabal file with the most recent version of yesod (1.6.0). Naively adding the dependencies amazonka-core and amazonka-ssm (for example) to my cabal file comes back with
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for my-project-0.0.0:
amazonka-core must match -any, but the stack configuration has no specified version
(latest matching version is 1.5.0)
amazonka-ssm must match -any, but the stack configuration has no specified version
(latest matching version is 1.5.0)
needed since my-project is a build target.
As suggested, I tried adding amazonka-core-1.5.0 and amazonka-ssm-1.5.0 to my stack.yaml file under extra-deps, but this doesn't work:
Warning: WARNING: /home/ubuntu/my-project/my-project.cabal was modified manually.
Ignoring package.yaml in favor of cabal file. If you want to use package.yaml
instead of the cabal file, then please delete the cabal file.
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for amazonka-core-1.5.0:
conduit-1.3.0.2 from stack configuration does not match >=1.1 && <1.3 (latest
matching version is 1.2.13.1)
needed due to my-project-0.0.0 -> amazonka-core-1.5.0
After a bit of digging, it seems that the snapshot that the yesod template was built off of is lts-11.6, but the most recent snapshot that the amazonka library is included in is lts-10.9. So, I tried building the project again from the yesod-mongo template, but this time specifying an older snapshot:
ubuntu:~$ stack new my-project yesod-mongo --resolver lts-10.9
Downloading template "yesod-mongo" to create project "my-project" in my-project/ ...
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- my-project/
Selected resolver: lts-10.9
Resolver 'lts-10.9' does not have all the packages to match your requirements.
classy-prelude version 1.3.1 found
- my-project requires ==1.4.*
classy-prelude-conduit version 1.3.1 found
- my-project requires ==1.4.*
classy-prelude-yesod version 1.3.1 found
- my-project requires ==1.4.*
http-conduit version 2.2.4 found
- my-project requires ==2.3.*
persistent version 2.7.1 found
- my-project requires ==2.8.*
persistent-mongoDB version 2.6.0 found
- my-project requires ==2.8.*
yesod version 1.4.5 found
- my-project requires ==1.6.*
yesod-auth version 1.4.21 found
- my-project requires ==1.6.*
yesod-core version 1.4.37.3 found
- my-project requires ==1.6.*
yesod-form version 1.4.16 found
- my-project requires ==1.6.*
yesod-static version 1.5.3.1 found
- my-project requires ==1.6.*
Using package flags:
- my-project: dev = False, library-only = False
Now I am at a loss and more than a little frustrated. It seems like perhaps the template is ignoring the snapshot specification. So, my question:
Is there a way to build the scaffolded site from a template that uses a specific snapshot to fill in the cabal and stack.yaml files? Is there anything else I can do to get this to work?
Happy to provide more information if it's helpful.
Edit: I also tried bumping down the versions of the packages in the above snippet, and while this solves the issue of building dependencies, now the scaffolded site doesn't compile (presumably because things have changed in a meaningful way from yesod-1.4.5 to yesod-1.6.0).
Unfortunately you can't use Commercial Haskell's stack templates with yesod and amazonka as of now. The reasons being:
There was a recent conduit rewrite in version 1.3
Some breaking changes were introduced in recent Yesod 1.6 which depends on conduit >= 1.3
Amazonka doesn't work with recent version of conduit
The only way for you to get it working is switching back to old version of stack templates (those templates which actually worked with stackage resolver 10.9) and then using that to create a new project. Fortunately, Stack supports custom stack templates:
$ stack new my-project https://raw.githubusercontent.com/github-user-id/stack-templates/master/my-template.hsfiles

Stack can't find Chart or Chart-cairo, though the cabal file calls for them

I'm trying to use Haskell stack (lts-6.12 resolver) to set up and run a small demo program for Chart. I created the project with stack new, stack init, etc. then modified the generated Main.hs, adding the demo code. I also added the Chart and Chart-cairo packages to the .cabal file and ran stack build. Lots and lots of packages installed, including Chart and Chart-cairo, judging from the output, and when it was finally done, it tried to compile Main.hs, but failed with the following errors:
/home/asdf/my-project/app/Main.hs:4:8:
Could not find module ‘Graphics.Rendering.Chart.Easy’
It is a member of the hidden package ‘Chart-1.6#Chart_Cz416CvPROo70VikOoIoki’.
Perhaps you need to add ‘Chart’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
/home/asdf/my-project/app/Main.hs:5:8:
Could not find module ‘Graphics.Rendering.Chart.Backend.Cairo’
It is a member of the hidden package ‘Chart-cairo-1.6#Chart_I1HGJHEm7pvIiSoYgOrXbq’.
Perhaps you need to add ‘Chart-cairo’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
How can stack be loading these packages successfully, then be somehow unable to find them later? How can it have the nerve (jk) to ask me to put the dependencies in my .cabal file, when it has already obtained them from there to load them in the first place?
Here is the dependency list:
$ stack list-dependencies
Chart 1.6
Chart-cairo 1.6
StateVar 1.1.0.4
adjunctions 4.3
array 0.5.1.0
base 4.8.2.0
base-orphans 0.5.4
bifunctors 5.2
binary 0.7.5.0
bytestring 0.10.6.0
cairo 0.13.1.1
colour 2.3.3
comonad 4.2.7.2
containers 0.5.6.2
contravariant 1.4
data-default-class 0.0.1
deepseq 1.4.1.1
distributive 0.5.0.2
exceptions 0.8.3
filepath 1.4.0.0
free 4.12.4
ghc-prim 0.4.0.0
hashable 1.2.4.0
hmatrix 0.17.0.2
integer-gmp 1.0.0.0
kan-extensions 4.2.3
lens 4.13
machine-learning 0.1.0.0
mtl 2.2.1
old-locale 1.0.0.7
operational 0.2.3.3
parallel 3.2.1.0
prelude-extras 0.4.0.3
primitive 0.6.1.0
profunctors 5.2
random 1.1
reflection 2.1.2
semigroupoids 5.0.1
semigroups 0.18.1
split 0.2.3.1
stm 2.4.4.1
storable-complex 0.2.2
tagged 0.8.4
template-haskell 2.10.0.0
text 1.2.2.1
time 1.5.0.1
transformers 0.4.2.0
transformers-compat 0.4.0.4
unordered-containers 0.2.7.1
utf8-string 1.0.1.1
vector 0.11.0.0
void 0.7.1
If you have both an executable and library stanza, try listing
the dependencies in both.
If your executable depends on those dependencies but you've only listed
them in your library stanza you'll get that error - dependencies from
different stanzas are independent of each other.

Dependency hell in cabal. It is really a hell

Different programming languages use different packaging systems.
In their varied approach, Java's Maven looks like the best bet for me since it maintains different version of jar files in seperately versioned folders and hence, there is no way one will end up in conflicting versions of a library.
Next comes python. Python's pip puts its packages into /usr/local/lib/python/dist-packages/site-packages. When there is a version conflict, one can use its virtualenv and live with it.
Nodejs supports installing packages both in local folders and global folders. Till date for me, i never had a dependency conflict in the global libraries.
Then I got fascinated by the haskell's style and started using cabal. First, i was installing my libraries inside /home/user1/.cabal. Then when the package system broke, one friend suggested me to remove two folders - /home/user1/.cabal && /home/user1/.ghc. Now, my first confusion arose, why does cabal's library files sit in two folders .cabal && .ghc. I cleaned the library folders, ~/.ghc and ~/.cabal and did cabal install from a package source for cabal-db-0.1.12. Now, there was a new error and i was surprised, because i had sanitized all local repositories. The error was,
Configuring Cabal-1.22.2.0...
Building Cabal-1.22.2.0...
Installed Cabal-1.22.2.0
cabal: Error: some packages failed to install:
ansi-terminal-0.6.2.1 failed during the configure step. The exception was:
user error (The package 'ansi-terminal' requires Cabal library version -any &&
>=1.6 but no suitable version is installed.)
Then I tried the safest bet - sandbox for cabal-db. It worked. Then i repeated sandboxing for another pacakge, ghc-pkg-autofix. I did,
cd ghc-pkg-autofix-0.2.0.1
cabal sandbox init
cabal install
And for sandbox where there are absolutely no external dependencies, there are errors again,
cabal: Could not resolve dependencies:
trying: ghc-pkg-autofix-0.2.0.1 (user goal)
trying: Cabal-1.22.2.0 (dependency of ghc-pkg-autofix-0.2.0.1)
next goal: process (dependency of ghc-pkg-autofix-0.2.0.1)
rejecting: process-1.2.0.0/installed-06c..., 1.2.3.0, 1.2.2.0, 1.2.1.0,
1.2.0.0, 1.1.0.2, 1.1.0.1, 1.1.0.0 (conflict: ghc-pkg-autofix => process>=1.0
&& <1.1)
rejecting: process-1.0.1.5, 1.0.1.4, 1.0.1.3, 1.0.1.2, 1.0.1.1, 1.0.0.0
(conflict: Cabal => process>=1.1.0.1 && <1.3)
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.
Am i doing something wrong (or) this kind of dependency conflicts are quite common in cabal? I see, managing dependencies in other languages are a lot simpler.
Note: I use cabal-install version 1.22.0.0 && The Glorious Glasgow Haskell Compilation System, version 7.8.4
"And for sandbox where there are absolutely no external dependencies" this is not true. A sandbox still has dependencies on the global package database. Things like Cabal, GHC, process are typically installed in the global package database. Here you want to install ghc-pkg-autofix which requires process 1.0, but you have a more recent version of process already installed. Are you sure you need ghc-pkg-autofix, it seems to be quite old.

Cannot resolve the dependency about yesod-auth-oauth package

I want to use Yesod web framework with yesod-auth-oauth, but I encountered a dependency problem while cabal-dev install:
/Users/kenta/myapp/oryza% cabal-dev install
Resolving dependencies...
cabal: cannot configure yesod-platform-1.0.2. It requires data-default ==0.4.0
For the dependency on data-default ==0.4.0 there are these packages:
data-default-0.4.0. However none of them are available.
data-default-0.4.0 was excluded because authenticate-oauth-1.3.0 requires
data-default ==0.3.*
data-default-0.4.0 was excluded because data-default-0.3.0 was selected
instead
data-default-0.4.0 was excluded because oryza-0.0.0 requires data-default
==0.3.*
I don't have any idea of what's wrong.
What I did is just inserting one line in Cabal file:
yesod-auth-oauth >= 1.0 && < 1.1
The default scaffolding works fine, which is created through yesod init.
The version information
yesod-core: 1.0.1
cabal-dev: 0.9.1 (build with Cabal 1.14.0)
cabal-install: 0.10.2
GHC: 7.0.4
OS: Mac OS X Lion
Thanks.
This looks like an overly restrictive upper bound in the authenticate-oauth package. It would be best to follow up directly with the maintainer of that package.
In general, these kinds of issues are a side-effect of following the Package Versioning Policy. Basically, it's a trade-off between having these "refuse to compile" annoyances and more insidious "can't compile" problems.
I don't remember for sure, but I think my change to the cabal file for yesod-auth-oauth fixes this.

Cannot install Yorgey et al's "unbound" library with latest GHC/Haskell Platform

Has anybody managed to get Yorgey et al's "unbound" library, for working with syntax with binding, to install with the latest GHC (7.0.3) and Haskell platform? Trying a cabal install unbound, I get the following:
Resolving dependencies...
cabal: cannot configure unbound-0.2.3. It requires base >=4.3 && <5
For the dependency on base >=4.3 && <5 there are these packages: base-4.3.0.0
and base-4.3.1.0. However none of them are available.
base-4.3.0.0 was excluded because of the top level dependency base -any
base-4.3.1.0 was excluded because of the top level dependency base -any
Anybody know a solution/work around, or what may be happening here?
Just to close this one:
The "unbound" library works fine with the 2011 Haskell Platform, and indeed, builds without warnings.
The OP had multiple (older) versions of GHC in his path, leading to build errors, since the package relies on GHC 7. Ensuring you have exactly the Haskell Platform environment is the solution.
As a note, we should write a script that checks the sanity of a given Haskell environment, to catch errors like this.

Resources