Haskell-Stack: Access violation error during build - haskell

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.

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!

stack install error: Recommended extra-dep

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.)

Stack has not been tested with GHC & Cabal versions

In my Haskell project when I stack run, it is showing the following, but still runs. What warning is this? How can I get rid of it?
Stack has not been tested with GHC versions above 8.6, and using 8.8.2, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
This is just a compatibility warning. The next stack version should be tested with GHC 8.8 and this warning should be gone. Until then there's probably little you can do unless you want to modify the source.
As the others said, this can be most likely be ignored. If you want to be on the super-safe side, edit your stack.yaml and downgrade the resolver back to 14.x (latest at this point is 14.27).
You can specify a resolver when creating a project to get rid of this warning:
stack new hello-world simple --resolver=lts-14.27
This may cause other warnings you actually care about to be suppressed, but if you run stack --verbosity error or stack --silent you won't see these warnings. For example
stack --verbosity error exec <your program>

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.

Node.js module "fibers" not taking the correct version

I'm pretty new to node.js and its package management system and its require. I'm having trouble with the following runtime error I'm getting after having installed a bunch of packages with npm install:
ERROR: Couldn't initialise framework "wdio-mocha-framework".
Error: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found
(required by <path>.../node_modules/fibers/bin/linux-ia32-v8-5.0/fibers.node)
at Error (native)
My understanding of the error is that the binary fibers.node was compiled with a newer libstdc++ than the one available at runtime.
It appears to me like the npm install did compile a fibers.node:
> fibers#1.0.13 install <path>.../node_modules/fibers
> node build.js || nodejs build.js
make[1]: Entering directory `<path>.../node_modules/fibers/build'
<snip some output, including warnings, here that I don't deem relevant>
Installed in `<path>.../node_modules/fibers/bin/linux-ia32-v8-3.14/fibers.node`
However, I see that the fibers.node that is throwing the error at runtime is not the same one as was compiled, and I assume that's the source of the problem.
Compiled:
.../linux-ia32-v8-3.14/fibers.node
Used at runtime and fails:
.../linux-ia32-v8-5.0/fibers.node
So I'm guessing and hoping that if I could convince wdio-mocha-framework to use the locally-compiled fibers.node, it would work. My questions are thus:
Would that fix it?
If so, how do I achieve that?
If not, what's the correct direction to take to further understand and fix this error? Perhaps instead of getting 3.14 to be used at runtime, I should be convincing 5.0 to be compiled at install-time? Or ... other?
Your help is most sincerely appreciated.
Update/Edit:
I think I solved this on my own, in case anyone ever finds this poor, dusty old question lying forgotten on the back of a shelf somewhere...
The problem was apparently due to multiple versions of node/node-gyp that were installed in my environment in parallel, and the build process, even though it was started with a newer version of node, was finding node-gyp in the $PATH and that's apparently what caused the old version of fibers to be built. At least, I think so.
Just had this problem recently. I managed to solve it just by uninstalling the current version of Node.JS (I had the most recent, in this case 9.5.0) and installing the recommended, in this case 8.9.4. and the issue is gone. hope this helps someone.

Resources