stack install error: Recommended extra-dep - haskell

I am currently trying to install stack to utilise the software Taiji. I have been able to run 'stack setup', but get an error when I run stack install:
C:\Users\My Name\Taiji-1.2.1>stack install
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for shelly-1.8.1:
unix needed, but the stack configuration has no specified version (latest matching version is 2.7.2.2)
needed due to Taiji-1.2.1 -> shelly-1.8.1
Some different approaches to resolving this:
* Recommended action: try adding the following to your extra-deps in C:\Users\My Name\Taiji-1.2.1\stack.yaml:
- unix-2.7.2.2#sha256:9e93f93cc5a065248120136e83a0a6d1ce93d6eb5ef2a2543f9593e93e164d24,3496
Plan construction failed.
I am guessing I'll have to install another package of some sort and put it into the Taiji-1.2.1 folder, but am not exactly sure how(I am completely new to stack/programming). Is anyone able to help me with this issue? Thanks kindly.

When you see this error, you will need to open stack.yaml (the error message contains the full path), find the line saying # extra-deps: [], and replace it with the line shown in the error message:
extra-deps:
- unix-2.7.2.2#sha256:9e93f93cc5a065248120136e83a0a6d1ce93d6eb5ef2a2543f9593e93e164d24,3496
(If you already have something listed in extra-deps, then you can just add that line to the end of extra-deps rather than replacing the whole thing.)
Now, this is usually enough. But you’ve got a further problem: you are using Windows, but you’re trying to compile a program which depends on the unix package — a package which is not available on Windows. Due to this, you will not be able to compile your program on Windows.
(As for why all that extra-deps stuff is needed: basically, Stack maintains a list of package versions known to work with each other, but occasionally you will run into a package which isn’t in that list. In that case you will need to list that package version in extra-deps to tell Stack which version to use.)

Related

How to fix InvalidAbsFile error from stack build

I seem to be getting a peculiar problem which is hard to even search up online.
I'm using stack and have already created a project from my professor but when I try to run it with stack build or stack run
I get this error:
InvalidAbsFile "C:\\Programs\\Projects\\bimaru2\\\"C:\\Windows\\system32\\ghc-9.0.2.exe"
The error is mentioned here: https://hackage.haskell.org/package/path-0.9.2/docs/Path-Windows.html#v:InvalidAbsFile but this description is not telling me anything.
I found someone with a similar problem: InvalidAbsFile error when running "stack" on windows in an existing project. I removed Java but the problem still persists. I tried changing directories and all, so the first path is printed according to where the project is. My version of ghc was 8.10.7 and I reinstalled 9.2.4, so I have no idea where 9.0.2 comes from (nor do I have it in C:\Windows\system32\ directory).
This is the second project I get this error with, but the first one I solved by setting system-ghc in stack.yaml file from true to false (although the professor mentioned that then it did not compile for him until he changed it back when we turned in the assignment).
packages:
- .
resolver: lts-18.28
compiler: ghc-8.10.7
compiler-check: match-exact
system-ghc: false
install-ghc: false
I tried the same with this one, but it did not work.
If needed, I will provide a link to the github repo where the project is located.
I'd be really grateful if you could help me get the project running. Thanks in advance!

Error installing haskelly to use with VSCode

I'm trying to install Haskelly so that I can use VSCode to build and debug Haskell. The issue here is that when I try to install intero, Quick Check and stack-run using the following command:
stack install intero QuickCheck stack-run
I get the following error:
Error: While constructing the build plan, the following exceptions
were encountered:
In the dependencies for stack-run-0.1.1.4:
conduit-1.3.1.1 from stack configuration does not match >1.1 && <1.3 (latest matching version is 1.2.13.1)
conduit-extra-1.3.4 from stack configuration does not match >=1.1 && <1.2 (latest matching version is 1.1.17) needed since stack-run is
a build target.
Some different approaches to resolving this:
Set 'allow-newer: true' in C:\sr\config.yaml to ignore all version
constraints and build anyway.
Recommended action: try adding the following to your extra-deps in
C:\sr\global-project\stack.yaml:
conduit-1.2.13.1#sha256:afd4db7fe66ae7af3d418e1a932384a8dee08df2f6299cca80e53ba964ce1228,4371
conduit-extra-1.1.17#sha256:dfa0d00dc11a8a4c3fdff15374c378ee34c25a2255b52194aa1ea3c1f1a63fd7,4521
Plan construction failed.
Now while it does provide some clues as to what I'm supposed to do, I have no clue what it means to add these things to stack.yaml. I found stack.yaml, and it's just a file that I seemingly can't open or modify. Does anyone know how I can fix this issue?
This is a problem installing stack-run, documented here: https://github.com/yamadapc/stack-run/issues/21.
I solved it by adding the following to my stack.yaml:
extra-deps:
- url: https://github.com/Magicloud/stack-run/archive/master.zip

Haskell-Stack: Access violation error during build

I've been trying to build my Haskell project for the last couple days using stack and I'm getting an access violation error. From what I understand I have the latest stack version and GHC.
This was all originally working until I added a library to my cabal file. I've now removed it but the error still occurs. I've also reverted back to when my code was definitely working so I'm sure this is something caused by stack.
I've tried uninstalling stack, deleting .stack-work and reinstalling. Then doing a stack setup. I've tried many variations of commands but no results.
I've now also tried creating a new project with Stack and building it and I get the same issue.
stack build
Building all executables for `haskell-project' once. After a successful build of all of them, only specified executables will be rebuilt.
haskell-project-0.1.0.0: configure (exe)
Access violation in generated code when reading 000000000e58391a
-- While building custom Setup.hs for package haskell-project-0.1.0.0 using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_2.0.1.0_ghc-8.2.2.exe --builddir=.stack-work\dist\5c8418a7 configure --with-ghc=C:\Users\Michael\AppData\Local\Programs\stack\x86_64-windows\ghc-8.2.2\bin\ghc.EXE --with-ghc-pkg=C:\Users\Michael\AppData\Local\Programs\stack\x86_64-windows\ghc-8.2.2\bin\ghc-pkg.EXE --user --package-db=clear --package-db=global --package-db=C:\sr\snapshots\13cecb13\pkgdb --package-db=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\pkgdb --libdir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\lib --bindir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\bin --datadir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\share --libexecdir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\libexec --sysconfdir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\etc --docdir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\doc\haskell-project-0.1.0.0 --htmldir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\doc\haskell-project-0.1.0.0 --haddockdir=C:\Users\Michael\Desktop\haskell-project\.stack-work\install\ccbce92a\doc\haskell-project-0.1.0.0 --dependency=base=base-4.10.1.0 --dependency=containers=containers-0.5.10.2 --dependency=mtl=mtl-2.2.1-DscMMmDQUE6GBfOSl4qMUH --dependency=parsec=parsec-3.1.11-3BgBURmbRiVF8fgoxhAiBa --dependency=pretty-simple=pretty-simple-2.0.1.0-J3QTM6x6LHL5fhqavYvVhJ --dependency=text=text-1.2.2.2-9VTsh6V7U7hpagw2HDvpZ --extra-include-dirs=C:\Users\Michael\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include --extra-lib-dirs=C:\Users\Michael\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\bin --extra-lib-dirs=C:\Users\Michael\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\lib --enable-tests --enable-benchmarks
Process exited with code: ExitFailure 1
What would be the steps to fix this or likely causes?
I managed to find a temporary solution for anybody who is having the same issue.
I downgraded cabal to version 1.24.0.2 and changed the resolver to using GHC version 8.0.1 (resolver: ghc-8.0.1).
After then running stack solver I'm now able to build.
The issue #3765 on the stack tracker has some workarounds for this, in addition to Michael's answer.
The best solution, it seems, is to unset __COMPAT_LAYER, which when set to INSTALLER can reproduce the bug.
C:\>set __COMPAT_LAYER=
The cause might be a bug in some versions of GHC, which is catching exceptions it ought to propagate to the user. If this is the case, there is an underlying problem, and this bug is hiding it.
Do please add a comment on the aforementioned issue, as it will help the maintainers track the prevalence of this problem.

Cabal update fails with 404 error trying to access a non existing file when compiling Apache Thrift

I'm trying to install Apache Thrift on my system, which performs a cabal update command. This command fails with the following message:
Downloading the latest package list from stackage cabal: Failed to download
http://www.stackage.org/stackage/7ae494fec2db3161dfb8e64677149285857478e0/00-index.tar.gz
: ErrorMisc "Error HTTP code: 404"
I normally use stack and I never had to do a cabal update manually. I don't know if the interaction between cabal and stack is a problem here.
Any ideas on how to fix this?
EDIT: Looking at my `~/.cabal/config~ I see the following entry:
remote-repo: stackage:http://www.stackage.org/stackage/7ae494fec2db3161dfb8e64677149285857478e0
So it seems that line is the culprit, but I don't know whether stack could have changed this for a good reason.

Installing specific versions via stack

So I suppose the problem I'm really trying to solve is that when I run ghc-mod I get this error:
CabalHelper/Licenses.hs|53 col 18 error| error: Ambiguous occurrence ‘lookupInstalledPackageId’
I found this relevant issue:
https://github.com/DanielG/ghc-mod/issues/772
Where it suggests installing ghc-mod from github,
I'd like to do everything via stack if possible (just to avoid mixing too many environments), but I couldn't find a way to specify either a version or how to specify a github repo with stack install.
I also continually run into errors from stack saying that it found version x when version y was required, but I can't seem to figure out how to get it to install version x anyways.
Anyone know how I can install the latest version of ghc-mod? Preferably with stack.
This was implemented recently. https://github.com/commercialhaskell/stack/issues/2028
Just use:
stack install ghc-mod-5.0.0
or any other version you like.

Resources