Stack only finds newer version of Cabal - haskell

I'm trying to build a project of mine using Stackage lts-13.12.
After Stack was complaining that the version of Cabal was too new, I've tried to install an older version:
cabal --version
cabal-install version 2.2.0.0
compiled using version 2.2.0.1 of the Cabal library
However, when I run stack solver, I get the following error:
Using configuration file: stack.yaml
Using cabal packages:
- ./
Using resolver: lts-13.12
Warning: Installed version of cabal-install (2.4.1.0) is newer than stack has been tested with. If you run into difficulties, consider downgrading.
Using compiler: ghc-8.6.4
Asking cabal to calculate a build plan...
Trying with packages from lts-13.12 and 1 external packages as hard constraints...
The following lines from cabal-install output could not be parsed:
optparse-applicative-0.14.3.0 (via: project-0.1.0.0 project-0.1.0.0) (new
package)
CallStack (from HasCallStack):
error, called at src/Stack/Solver.hs:174:16 in stack-1.9.3-F7FXKCpM3pk5wCtbL9Utvv:Stack.Solver
My questions are:
Why is Stack seeing the newer Cabal? How can I make it see the older one?
Why is Stack incompatible with Cabal 2.4.1.0, when that's the version in the Stackage LTS 13.12?
I'm running Version 1.9.3 of Stack, if that makes a difference.

Stack solver error messages are known to be bad and choke on cabal output. I don't believe this feature is well maintained.
I do wish stack would update its errors and warnings. Sticking with cabal-install-2.4.1.0 is probably the best choice.
Instead of using stack solver, I recommend you force it to use lts-13.12 and then add extra deps by hand to address any issues you encounter. Most of the time stack will helpfully recommend the right extra deps (without using the solver), but you do need to apply some intuition to make sure they are right.

Related

Is there a way for `stack --nix` to allow newer versions of ghc to be used?

I'm running stack --nix init for a new project (xmonad config) and getting error: attribute 'ghc863' missing, at (string):1:43; I have ghc 8.6.5 in the environment, and stack --version reports: 2.1.3.1 x86_64 hpack-0.32.0. My project is roughly following this blog post for building XMonad (with exceptions made to do things using Nix where possible), and so far only consists of cloning the three repos into .xmonad and running stack --nix init; the three repos are: xmobar, xmonad-contrib, xmonad.
Is there a way for stack --nix to allow newer versions of ghc to be used? Or are there other possible causes for the issue?
I saw stack --nix build complains about ghc version mismatch but felt this didn't really illuminate the issue, though it does suggest possibly alternatives using cabal/nix.

stack 1.6.5 not working with cabal 2.0.0.1

I have stack 1.6.5 but see the error described in Cabal 2.0 required when using a nightly snapshot with stack. I understand that the problem was solved in stack v 1.5.1, but I see it in 1.6.5:
Using resolver: lts-11.2
Warning: Installed version of cabal-install (2.0.0.1) is newer than stack has been tested with. If you run into difficulties, consider downgrading.
Using compiler: ghc-8.2.2
Asking cabal to calculate a build plan...
Trying with packages from lts-11.2 and 3 external packages as hard constraints...
The following lines from cabal-install output could not be parsed:
abstract-par-0.3.3 (via: monad-par-0.3.4.8 monad-par-extras-0.3.3) (new
package)
base-compat-0.9.3 (via: criterion-1.3.0.0 criterion-1.3.0.0 aeson-pretty-0.8.5
aeson-1.2.4.0 quickcheck-instances-0.3.18) (new package)
stack upgrade gives:
frank#oporto:~/Workspace8/LitTextWork/LitText$ stack upgrade
Current Stack version: 1.6.5, available download version: 1.6.5
Skipping binary upgrade, you are already running the most recent version
I assume that the output is harmless, but should be bypassed in this version? How would I downgrad the cabal? What is the last cabal version recommended?
Stack issues #3453 and #3799 suggest this is a known bug in Stack. Until a fix for it lands, a makeshift workaround suggested in a comment to #3453 is using stack --resolver lts-9 install cabal-install to install cabal-install 1.24.0.2 (the executable, not the library).
Caveats:
The workaround assumes the local installation path Stack uses (cf. what stack path --local-bin tells you) has priority over the path of the globally installed cabal-install in hour PATH environment variable, or if you don't have a globally installed cabal-install to begin with (e.g. if you aren't using the Haskell Platform).
As hvr points out, this is not officially supported as far as Cabal and GHC are concerned, and you might run into further issues if features from newer cabal-install versions ever turn out to be necessary while using the solver via Stack.
If you ever need or want to have an up-to-date cabal-install, just use stack install cabal-install -- which will do it with the resolver you are using elsewhere. (If you have a globally installed cabal-install and want to go back to using it, you can simply delete the Stack-installed one from the location indicated by stack path --local-bin.)

How to update to GHC 8.0

I am trying to use the Quantum Programming language Quipper, and I am running into issues due to the version of GHC I am using:
root#ubuntu:~$ apt-show-versions ghc
ghc:amd64/xenial 7.10.3-7 uptodate
ghc:i386 not installed
As it turns out, 7.10 is the only version that Quipper cannot compile with.
I then discovered that apparently the only way to install Haskell 8.0 was using haskell-stack. Ok, I've never installed something on a stack, so this will go over well.
So I used the instructions on this website to install haskell-stack, then ran the commands:
root#ubuntu:~$ stack setup
root#ubuntu:~$ stack update
root#ubuntu:~$ stack install ghc
The last command returned the following:
Didn't see ghc-8.0.2 in your package indices.
Updating and trying again.
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpc Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpc Downloading timestamp
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpc Downloading snapshot
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpc Updating index
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpc Updated package list downloaded
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpc Populated index cache.
The following package identifiers were not found in your indices: ghc-8.0.2
Perhaps you meant AAI, AAI, AAI, AES, AES, AES, AES, AES, AES, or AES?
So, a quick check again:
root#ubuntu:~$ apt-show-versions ghc
ghc:amd64/xenial 7.10.3-7 uptodate
ghc:i386 not installed
Nope, still 7.10. Tried also to download the package from this website. The package failed to be extracted, so that's a good sign. Rinsed and repeated the above commands, and still nothing. Then I edited the stack.yaml file to say:
resolver: lts-9.14
resolver: ghc-8.0.2
Did absolutely nothing. What step am I missing? Its frustrating when people basically say "the stack does everything for you" and I'm like "what exactly am I supposed to do?"
EDIT
As I said above, downloading the package for 8.0.2 from haskell.org gives fails to extract the archive:
Don't jump into installing the binaries directly. While, as others mentioned, stack isn't the only way, it is certainly one of the easier ones.
So first thing, stack setup actually downloads GHC for you based on the resolver it finds. If you are not in a stack project, it'll default to the global stack config. On the other hand stack install is used for installing packages. That means doing stack install ghc is trying to look for a package on stackage that's called ghc, of which I don't think there are any.
To run the GHC that stack installed, you'll do stack ghc and to get a GHCi session, stack ghci (generally just prefix with stack).
You could also run the general stack exec -- .. to run a command with stack's path variables. E.g. stack exec -- ghci will work here as well, or stack exec -- ghc --version to get the GHC version.
Binary distributions of GHC can be obtained from GHC HQ:
8.0.2 here https://www.haskell.org/ghc/download_ghc_8_0_2.html#binaries
8.2.2 here https://www.haskell.org/ghc/download_ghc_8_2_2.html#binaries
Any suggestion that any one tool is necessary to obtain GHC is wrong.
EDIT: On a nix computer, for example, one can do the following (approx, not tested):
wget https://downloads.haskell.org/~ghc/8.2.2/ghc-8.2.2-x86_64-deb8-linux.tar.xz
tar xJf ghc-8.2.2*
cd ghc*
./configure --prefix=$HOME
make install
If you don't like portable shell and really want to use apt then consider using hvr's PPA which is pretty darn popular.

Can haskell-src-meta be installed to be used with GHC 7.10.1?

I tried, but I got this error:
https://gist.github.com/Wizek/a3e02b93b9f672a91f54
I remember trying with GHC 7.8.4 too, and AFAIR that also failed similarly.
Misc
I've used a new & empty cabal sandbox
cabal-install version 1.22.2.0
Looks like your happy executable needs to be upgraded. You can install the new version with cabal-install. Alternatively, using stack will automatically install the correct version of happy.

Cannot cabal install hs3 (for haskell-supercollider)

(Ubuntu 12.04)
Hello!
I'm trying to get hs3 installed to my haskell platform so that I can use the haskore-supercollider package (it's a required dependency). However, when I attempt cabal install, it crashes on the some files I believe to be related to hosc. Here's a text readout of the error:
Sound/SC3/UGen/Help.hs:26:46: Not in scope: `lookupEnv'
cabal: Error: some packages failed to install:
hsc3-0.15 failed during the building phase. The exception was:
ExitFailure 1
I've attempted a number of things including updating cabal, reinstalling hosc, and throwing some flags on the install, or getting the install from a different source (slavepianos.org). Still though, I keep getting the same error. Here's an image of the error for reference:
http://i.stack.imgur.com/dGEKx.png
Thanks for your help!
You appear to have reached "Cabal Hell".
It looks to me like hsc3 for versions later than 0.13 depends on GHC being at least version 7.6 (the version which added the lookupEnv function), while Ubuntu 12.0.4 provides 7.4. This shows up as a compilation error because hsc3 has a badly set version bound on the base package.
You might try either of:
Installing a later version of GHC. It's currently at 7.8 with 7.10 expected out next month.
Using the older haskore-supercollider version 0.2, which uses hsc3 0.13. (Alas, when I try this with --dry-run, cabal fails to find an installation plan, but perhaps it works better if you actually have GHC 7.4.)

Resources