Package Management with Stack?

I've gotten fed up with Cabal+Hackage build errors and I want a more stable way to manage Haskell packages. I'm NOT trying to build a Haskell project of my own, but I just want a system-wide (or at least user-wide) installation of GHC "with batteries", along with some Haskell programs that other people have written. I need xmonad installed somewhere on my $PATH and I need lens available with :m+ when I fire up ghci. I do NOT want a bunch of sandboxes scattered throughout my file system, some of which have these things installed while others don't. I was hoping Stack+Stackage would fit that bill, but going through the instructions on https://haskell-lang.org/get-started, it seems that stack is meant really for setting up sandboxes for particular projects. When I tried using it as a system-wide (or rather, user-wide) package manager, it fails. For instance, as suggested on that page, I created /tmp/HelloWorld.hs and type $ stack HelloWorld.hs which seemed to successfully download the lts-8.4 build plan and ghc-nopie-8.0.2. So far so good. But then when I typed $ stack install xmonad-contrib it said Error: While constructing the build plan, the following exceptions were encountered: In the dependencies for xmonad-contrib-0.13: X11-xft must match >=0.2, but the stack configuration has no specified version (latest applicable is 0.3.1) Recommended action: try adding the following to your extra-deps in /home/jun/.stack/global-project/stack.yaml: - X11-xft-0.3.1 You may also want to try the 'stack solver' command Plan construction failed. I've tried going down the "stack solver" rabbit hole, to no avail; it just tells me I need to register a directory containing a .cabal file. IIUC, that's a directory containing some project I'm developing? But I have no such project! (At the moment.) Am I fundamentally misunderstanding how stack is supposed to be used? Is stack usable as a package manager in the way cabal sort of was, and in the way apt-get or emerge can be used? If not, what do people recommend I use for that purpose? Nix? Or, perhaps, do the errors above indicate misconfiguration? I don't want to install haskell-platform because it's too outdated. I need at least GHC >= 8. I'm on the latest stable release of Ubuntu if that makes a difference. -- Jun Inoue

On Fri, Mar 10, 2017 at 12:28 PM, Jun Inoue
Am I fundamentally misunderstanding how stack is supposed to be used?
Stack is not a package manager. It is a reproducible builds tool. Ad hoc usage like you are doing is outside of its purview. Also, last I checked, for some reason xmonad-contrib wasn't in stackage, so stack's primary mechanism for avoiding conflicts fails. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Stack does have a notion of a global project, which it uses if you're not
in a project directory. The error message you received:
Error: While constructing the build plan, the following exceptions
were encountered:
In the dependencies for xmonad-contrib-0.13:
X11-xft must match >=0.2, but the stack configuration has no
specified version (latest applicable is 0.3.1)
Recommended action: try adding the following to your extra-deps in
/home/jun/.stack/global-project/stack.yaml:
- X11-xft-0.3.1
tells you how to make X11-xft-0.3.1 available to the global project, which
should allow you to install xmonad-contrib into this global package.
Matt Parsons
On Fri, Mar 10, 2017 at 10:33 AM, Brandon Allbery
On Fri, Mar 10, 2017 at 12:28 PM, Jun Inoue
wrote: Am I fundamentally misunderstanding how stack is supposed to be used?
Stack is not a package manager. It is a reproducible builds tool. Ad hoc usage like you are doing is outside of its purview.
Also, last I checked, for some reason xmonad-contrib wasn't in stackage, so stack's primary mechanism for avoiding conflicts fails.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

I use the global stack environment to install most executables, it works
best when the package is in a snapshot of course. There is no need to
change the global config, try this: stack install xmonad-contrib
X11-xft-0.3.1 --resolver lts-8.4
You can also look for a stack.yaml in the repo of the executable and use
that resolver + any extra deps on the command line, that'll most likely
work even if the package isn't in a snapshot.
HTH,
Adam
On Fri, 10 Mar 2017 at 18:56 Matt
Stack does have a notion of a global project, which it uses if you're not in a project directory. The error message you received:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for xmonad-contrib-0.13: X11-xft must match >=0.2, but the stack configuration has no specified version (latest applicable is 0.3.1)
Recommended action: try adding the following to your extra-deps in /home/jun/.stack/global-project/stack.yaml: - X11-xft-0.3.1
tells you how to make X11-xft-0.3.1 available to the global project, which should allow you to install xmonad-contrib into this global package.
Matt Parsons
On Fri, Mar 10, 2017 at 10:33 AM, Brandon Allbery
wrote: On Fri, Mar 10, 2017 at 12:28 PM, Jun Inoue
wrote: Am I fundamentally misunderstanding how stack is supposed to be used?
Stack is not a package manager. It is a reproducible builds tool. Ad hoc usage like you are doing is outside of its purview.
Also, last I checked, for some reason xmonad-contrib wasn't in stackage, so stack's primary mechanism for avoiding conflicts fails.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

On Fri, Mar 10, 2017 at 2:11 PM, Adam Bergmark
You can also look for a stack.yaml in the repo of the executable and use that resolver + any extra deps on the command line, that'll most likely work even if the package isn't in a snapshot.
"most likely" --- but it can fail. The point of having projects is to ensure they can't conflict with each other. If you install something in one and it's compatible with others, you can use it without redownloading/recompiling (in effect it gets mirrored into the new project). But if you slam everything into the global project, you can set up conflicts similar to those you get with cabal-install without sandboxes. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

How can you get these conflicts in the global stack project? I've never had
such issues. Packages are still sandboxed on a per-snapshot basis, I'm not
sure how extra-deps are handled here but they don't seem to cause any
conflicts.
On Fri, 10 Mar 2017 at 20:25 Brandon Allbery
On Fri, Mar 10, 2017 at 2:11 PM, Adam Bergmark
wrote: You can also look for a stack.yaml in the repo of the executable and use that resolver + any extra deps on the command line, that'll most likely work even if the package isn't in a snapshot.
"most likely" --- but it can fail.
The point of having projects is to ensure they can't conflict with each other. If you install something in one and it's compatible with others, you can use it without redownloading/recompiling (in effect it gets mirrored into the new project). But if you slam everything into the global project, you can set up conflicts similar to those you get with cabal-install without sandboxes.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On Fri, Mar 10, 2017 at 2:34 PM, Adam Bergmark
How can you get these conflicts in the global stack project? I've never had such issues. Packages are still sandboxed on a per-snapshot basis, I'm not sure how extra-deps are handled here but they don't seem to cause any conflicts.
I couldn't tell you internal details but every so often we see in #haskell someone who's put a few too many things in there and ends up resetting stack (removing ~/.stack and/or ~/.stack-work) to undo the damage. I *think* it's partially hidden by packages being managed per resolver/snapshot, but extra-deps can still get you in trouble if they conflict. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Thanks for the suggestion, Adam. That does it for xmonad-contrib.
Unfortunately, it fails when I go on to add xmonad-extras, probably
because the version of xmonad already installed can't be resolved with
the available version(s) of xmonad-extras. (I forgot to note exactly
which packages I had before, so I'm installing these things one by
one, based on compilation errors of ~/.xmonad/xmonad.hs.)
$ stack install xmonad-extras hint-0.6.0 libmpd-0.9.0.6 --resolver lts-8.4
Error: While constructing the build plan, the following exceptions
were encountered:
In the dependencies for xmonad-extras-0.12.1:
hint-0.6.0 must match >=0.3.3.3 && <0.5 (latest applicable is 0.4.3)
libmpd-0.9.0.6 must match >=0.8 && <0.9 (latest applicable is 0.8.0.5)
xmonad-0.13 must match >=0.10 && <0.13 (latest applicable is 0.12)
xmonad-contrib must match >=0.10 && <0.13, but the stack
configuration has no specified version
(latest applicable is 0.12)
Recommended action: try adding the following to your extra-deps in
/home/jun/.stack/global-project/stack.yaml:
- xmonad-contrib-0.12
You may also want to try the 'stack solver' command
Plan construction failed.
Adding the fact that I seem to have to list a lot of deps on the
command line or in stack.yaml and Brandon's suggestion that I'm using
this tool for the wrong purpose, this seems like a deal breaker for me
:(
On Sat, Mar 11, 2017 at 4:11 AM, Adam Bergmark
I use the global stack environment to install most executables, it works best when the package is in a snapshot of course. There is no need to change the global config, try this: stack install xmonad-contrib X11-xft-0.3.1 --resolver lts-8.4
You can also look for a stack.yaml in the repo of the executable and use that resolver + any extra deps on the command line, that'll most likely work even if the package isn't in a snapshot.
HTH, Adam
On Fri, 10 Mar 2017 at 18:56 Matt
wrote: Stack does have a notion of a global project, which it uses if you're not in a project directory. The error message you received:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for xmonad-contrib-0.13: X11-xft must match >=0.2, but the stack configuration has no specified version (latest applicable is 0.3.1)
Recommended action: try adding the following to your extra-deps in /home/jun/.stack/global-project/stack.yaml: - X11-xft-0.3.1
tells you how to make X11-xft-0.3.1 available to the global project, which should allow you to install xmonad-contrib into this global package.
Matt Parsons
On Fri, Mar 10, 2017 at 10:33 AM, Brandon Allbery
wrote: On Fri, Mar 10, 2017 at 12:28 PM, Jun Inoue
wrote: Am I fundamentally misunderstanding how stack is supposed to be used?
Stack is not a package manager. It is a reproducible builds tool. Ad hoc usage like you are doing is outside of its purview.
Also, last I checked, for some reason xmonad-contrib wasn't in stackage, so stack's primary mechanism for avoiding conflicts fails.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- Jun Inoue

On Fri, Mar 10, 2017 at 7:37 PM, Jun Inoue
because the version of xmonad already installed can't be resolved with the available version(s) of xmonad-extras.
I think we have a PR for that already, don't recall if it's been applied or not, certainly there has not been a release of it. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On Sat, 11 Mar 2017 at 01:38 Jun Inoue
Thanks for the suggestion, Adam. That does it for xmonad-contrib. Unfortunately, it fails when I go on to add xmonad-extras, probably because the version of xmonad already installed can't be resolved with the available version(s) of xmonad-extras. (I forgot to note exactly which packages I had before, so I'm installing these things one by one, based on compilation errors of ~/.xmonad/xmonad.hs.)
$ stack install xmonad-extras hint-0.6.0 libmpd-0.9.0.6 --resolver lts-8.4
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for xmonad-extras-0.12.1: hint-0.6.0 must match >=0.3.3.3 && <0.5 (latest applicable is 0.4.3) libmpd-0.9.0.6 must match >=0.8 && <0.9 (latest applicable is 0.8.0.5) xmonad-0.13 must match >=0.10 && <0.13 (latest applicable is 0.12) xmonad-contrib must match >=0.10 && <0.13, but the stack configuration has no specified version (latest applicable is 0.12)
Recommended action: try adding the following to your extra-deps in /home/jun/.stack/global-project/stack.yaml: - xmonad-contrib-0.12
You may also want to try the 'stack solver' command Plan construction failed.
Adding the fact that I seem to have to list a lot of deps on the command line or in stack.yaml and Brandon's suggestion that I'm using this tool for the wrong purpose, this seems like a deal breaker for me :(
It's not that you are using the wrong tool, there is no tool that would let you install incompatible versions together! (There is --allow-newer in stack and cabal-install but then you are even less likely to end up with something that works) But once you get these mismatches I find cabal-install (in an empty sandbox) easier to use for debugging: ``` $ cabal install xmonad xmonad-contrib xmonad-extras --dry Resolving dependencies... In order, the following would be installed (use -v for more details): data-default-class-0.1.2.0 data-default-instances-containers-0.0.1 dlist-0.8.0.2 data-default-instances-dlist-0.0.1 extensible-exceptions-0.1.1.4 mtl-2.2.1 old-locale-1.0.0.7 data-default-instances-old-locale-0.0.1 data-default-0.7.1.1 X11-1.6.1.2 (latest: 1.8) old-time-1.1.0.3 random-1.1 regex-base-0.93.2 regex-posix-0.95.2 setlocale-1.0.0.4 split-0.2.3.1 text-1.2.2.1 parsec-3.1.11 utf8-string-1.0.1.1 X11-xft-0.3.1 xmonad-0.12 (latest: 0.13) xmonad-contrib-0.12 (latest: 0.13) xmonad-extras-0.12.1 ``` cabal-install always tries to pick the latest versions so this implies that xmonad-extras can't use the latest xmonad & xmonad-contrib. So if you are fine using older versions of those: there you go! You can verify this further by adding constraints: ``` $ cabal install 'xmonad>=0.13' 'xmonad-contrib>=0.13' xmonad-extras --dry Resolving dependencies... cabal: Could not resolve dependencies: trying: xmonad-0.13 (user goal) trying: base-4.9.1.0/installed-4.9... (dependency of xmonad-0.13) next goal: xmonad-extras (user goal) rejecting: xmonad-extras-0.12.1, xmonad-extras-0.12 (conflict: xmonad==0.13, xmonad-extras => xmonad>=0.10 && <0.13) rejecting: xmonad-extras-0.11 (conflict: xmonad==0.13, xmonad-extras => xmonad>=0.10 && <0.12) rejecting: xmonad-extras-0.10.1.2, xmonad-extras-0.10.1.1, xmonad-extras-0.10.1, xmonad-extras-0.10 (conflict: xmonad==0.13, xmonad-extras => xmonad>=0.10 && <0.11) rejecting: xmonad-extras-0.9.2, xmonad-extras-0.9.1 (conflict: xmonad==0.13, xmonad-extras => xmonad>=0.9 && <0.10) rejecting: xmonad-extras-0.9, xmonad-extras-0.0 (conflict: base==4.9.1.0/installed-4.9..., xmonad-extras => base>=3 && <4 || <3) Dependency tree exhaustively searched. ``` What you really want is some blessed combination of packages that work together, and this is exactly what a stackage snapshot would give you if these packages were all part of stackage... But it's true that stack isn't a package manager and there is no active effort within stackage to make as many executables as possible installable.
On Sat, Mar 11, 2017 at 4:11 AM, Adam Bergmark
wrote: I use the global stack environment to install most executables, it works best when the package is in a snapshot of course. There is no need to change the global config, try this: stack install xmonad-contrib X11-xft-0.3.1 --resolver lts-8.4
You can also look for a stack.yaml in the repo of the executable and use that resolver + any extra deps on the command line, that'll most likely work even if the package isn't in a snapshot.
HTH, Adam
On Fri, 10 Mar 2017 at 18:56 Matt
wrote: Stack does have a notion of a global project, which it uses if you're
not
in a project directory. The error message you received:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for xmonad-contrib-0.13: X11-xft must match >=0.2, but the stack configuration has no specified version (latest applicable is 0.3.1)
Recommended action: try adding the following to your extra-deps in /home/jun/.stack/global-project/stack.yaml: - X11-xft-0.3.1
tells you how to make X11-xft-0.3.1 available to the global project, which should allow you to install xmonad-contrib into this global package.
Matt Parsons
On Fri, Mar 10, 2017 at 10:33 AM, Brandon Allbery
wrote: On Fri, Mar 10, 2017 at 12:28 PM, Jun Inoue
wrote:
Am I fundamentally misunderstanding how stack is supposed to be used?
Stack is not a package manager. It is a reproducible builds tool. Ad hoc usage like you are doing is outside of its purview.
Also, last I checked, for some reason xmonad-contrib wasn't in stackage, so stack's primary mechanism for avoiding conflicts fails.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- Jun Inoue

Am 11.03.2017 um 13:21 schrieb Adam Bergmark:
It's not that you are using the wrong tool, there is no tool that would let you install incompatible versions together! (There is --allow-newer in stack and cabal-install but then you are even less likely to end up with something that works)
What about the cabal new-build? Works like a charm for me. Cheers Ben

I see. That explains a lot of things, esp. that xmonad-contrib isn't
on stackage...
Is there anything else I could use the way I'm trying to do,
preferably leveraging the stability of the curated package list on
Stackage for those packages that have been curated?
On Sat, Mar 11, 2017 at 2:33 AM, Brandon Allbery
On Fri, Mar 10, 2017 at 12:28 PM, Jun Inoue
wrote: Am I fundamentally misunderstanding how stack is supposed to be used?
Stack is not a package manager. It is a reproducible builds tool. Ad hoc usage like you are doing is outside of its purview.
Also, last I checked, for some reason xmonad-contrib wasn't in stackage, so stack's primary mechanism for avoiding conflicts fails.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-- Jun Inoue
participants (5)
-
Adam Bergmark
-
Ben Franksen
-
Brandon Allbery
-
Jun Inoue
-
Matt