Error booting ghcjs in nixos from a stack project - haskell

I'm encountering an error running the boot stage of GHCJS in Nixos. GHCJS is being installed by stack with:
stack setup
And it fails during "installing stage 0" with:
solver must be one of: modular
My stack.yaml looks like:
resolver: lts-7.19
compiler: ghcjs-0.2.1.9007019_ghc-8.0.1
compiler-check: match-exact
(...)
setup-info:
ghcjs:
source:
ghcjs-0.2.1.9007019_ghc-8.0.1:
url: http://ghcjs.tolysz.org/ghc-8.0-2017-02-05-lts-7.19-9007019.tar.gz
sha1: d2cfc25f9cda32a25a87d9af68891b2186ee52f9
I've read that this was due to an incompatibility between cabal-install 2.0 and GHCJS. Even though I've been unable to find a way to fix it. Is there any way to make it build?

Related

Trying to compile gi-gtk-declarative

I am new to GTK, but not to Haskell. I am currently running Arch linux.
I cloned gi-gtk-declarative, and did a checkout of the release-0.6.3 branch.
I tried compiling with both stack build and cabal v2-build all, and both fail on gi-glib with the following error:
> Unknown GIR element "docsection" when processing namespace "GLib", aborting.
How can I fix this? Is there a patched version of gi-glib?
This looks like an issue regarding version constraints:
gi-gtk-declarative depends on haskell-gi (>=0.21 && <0.24)
Looks like this issue was fixed on haskell-gi 0.24.4
As you can see, the author of gi-gtk-declarative needs to update his dependencies.
As a workaround, you can run stack build --allow-newer or cabal build --allow-newer which will bypass the version constraint.

stack does not resolve dependencies when installing hip

I want to install the Haskell libary hip from https://hackage.haskell.org/package/hip by using stack. This does not work, because stack seems to not being able to install dependencies.
I have stack freshly installed by curl -sSL https://get.haskellstack.org/ | sh, and stack --version gives me
Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpack-0.31.1
I have tried several things like another resolver, reinstalling different versions of stack, ghc or cabal.
I have tried stack new test, and inside the test folder, i wrote stack install hip.
I got the following error:
Error: While constructing the build plan, the following exceptions were
encountered:
In the dependencies for hip-1.5.3.0:
Chart must match >=1.5, but the stack configuration has no specified
version (latest matching version is 1.9)
Chart-diagrams must match >=1.5, but the stack configuration has no
specified version (latest matching version is 1.9)
needed since hip is a build target.
Some different approaches to resolving this:
* Consider trying 'stack solver', which uses the cabal-install solver to
attempt to find some working build configuration. This can be convenient
when dealing with many complicated constraint errors, but results may be
unpredictable.
* Recommended action: try adding the following to your extra-deps
in /home/jarek/Desktop/test/stack.yaml:
Chart-1.9#sha256:f41568b6b3704f66c2ec163295b430ab7d798f91de426c2d5aba747d1135cd9b
Chart-diagrams-1.9#sha256:cdd0c22d730e507f9644e690833096ee127302b5ff5e1571f6def419160a2642
Plan construction failed.
I expect something like:
Building dependencies...
Installing Chart-1.9
...
...
...
hip successfully installed.
Please tell me if i did not provide all infos necessary for you to help me with my problem.
Installing with the resolver lts-7.5 works.
Why not do what stack recommended?
Recommended action: try adding the following to your extra-deps
in /home/jarek/Desktop/test/stack.yaml:
Chart-1.9#sha256:f41568b6b3704f66c2ec163295b430ab7d798f91de426c2d5aba747d1135cd9b
Chart-diagrams-1.9#sha256:cdd0c22d730e507f9644e690833096ee127302b5ff5e1571f6def419160a
It's the easiest way to accomplish your goal.
Update: lts-10.10 is the most recent resolver to include hip. If you update your stack.yaml to use lts-10.10 and add hip in your .cabal file, you should be good to go.

Cabal 2.0 required when using a nightly snapshot with stack

I'm trying to setup a new project using the nightly-2017-08-17 snapshot
stack new test --resolver nightly-2017-08-17
However this gives the following error:
Downloading template "new-template" to create project "test" in test/ ...
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- test/test.cabal
Selected resolver: nightly-2017-08-17
Unable to parse cabal file: FromString "This package requires at least Cabal version 2.0" Nothing
Cabal is in its latest version:
stack setup --upgrade-cabal
Currently installed Cabal is 2.0.0.2, newest is 2.0.0.2. I'm not upgrading Cabal.
stack will use a sandboxed GHC it installed
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec
Is this not the correct way of selecting this nightly snapshot with stack or is this a bug in the tool?
Cabal's file format has changed in the 2.0 release of it (likely because of backpack). You have to use Stack version >= 1.5.1 which bypasses this error. A proper fix for this will be likely released in the next version of Stack. IIRC, the fix is already in the master brach of the stack - so the upgrade via --source-only willl also work for you.
You can read the changelog here to know more information about it.

Dependency issues when using 'stack build --profile'?

Steps to reproduce:
$ stack new profiling-test
$ cd profiling-test
$ stack build --profile
A new project is initialized with lts-7.2 and a default template. I get the error:
While constructing the BuildPlan the following exceptions were encountered:
-- While attempting to add dependency,
Could not find package base in known packages
-- Failure when adding dependencies:
base: needed (>=4.7 && <5), stack configuration has no specified version (latest applicable is 4.9.0.0)
needed for package profiling-test-0.1.0.0
Recommended action: try adding the following to your extra-deps in ~/profiling-test/stack.yaml
- base-4.9.0.0
You may also want to try the 'stack solver' command
If I just do stack build, it compiles fine without any errors.
I've added base-4.9.0.0 to extra-deps in stack.yaml, but I get the same error.
My stack version is:
$ stack --version
Version 1.1.3, Git revision 225df244ea346a8dc880ef911b002583486a92b2 x86_64 hpack-0.14.0
And I'm running Ubuntu 14.04 trusty.
Thanks in advance for any help!
Figured it out after finding https://github.com/commercialhaskell/stack/issues/1331.
Solution:
Instead of doing
$ stack build --profile
Do:
$ stack build --profile --no-system-ghc
And just add --no-system-ghc to everything. You might potentially need to do stack setup --no-system-ghc before everything too?
Alternatively, as suggested by the comments, you can add this to the stack.yaml for the project or for your global stack project.

Cannot install accelerate-cuda in Haskell

I am on a linux box and trying to experiment with Haskell's Accelerate library but having problems installing it. I have successfully installed the accelerate package but there seems to be a dependency problem, which I have detailed below.
cabal: Error: some packages failed to install:
accelerate-cuda-0.14.0.0 depends on haskell-src-exts-1.14.0.1 which failed to
install.
cuda-0.5.1.1 failed during the configure step. The exception was:
ExitFailure 1
haskell-src-exts-1.14.0.1 failed during the configure step. The exception was:
ExitFailure 1
haskell-src-meta-0.6.0.5 depends on haskell-src-exts-1.14.0.1 which failed to
install.
language-c-quote-0.7.6 depends on haskell-src-exts-1.14.0.1 which failed to
install.
I searched SO and noticed someone else had a similiar issue installed the cuda package, and was resolved by adding the cabal bin path to the PATH; I tried this but it didn't solve this problem.
Please could someone help as I really keen to play with this fantastic library.
I wanted to check accelerate-examples and play with them and I also didn't have CUDA GPU (AMD only) and that's how I eventually installed accelerate-examples with stack:
git clone https://github.com/AccelerateHS/accelerate-examples
cd accelerate-examples
#choose version:
ln stack-8.6.yaml stack.yaml
#build without CUDA targeting:
stack build --flag accelerate-examples:-llvm-ptx --flag accelerate-fft:-llvm-ptx
Installation will build all the examples and print the info regarding where they was put.
Might also need to specify GHC libs path with something like: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.stack/programs/x86_64-linux/ghc-8.6.5/lib/ghc-8.6.5/rts/
Also checked that accelerate installs as well the same way but even without specifying any flags (I guess because it doesn't build any programs yet?), but examples are what's fun :)
P.S. You can move llvm-ptx flags to stack.yaml config: change # flags: {} line to:
flags:
accelerate-fft:
llvm-ptx: false
accelerate-examples:
llvm-ptx: false

Resources