cabal could not find module snap.internal.http.server.exception - haskell

I have a Haskell desktop application that uses Snap. This application has been building for years now and is an everyday part of our fielded solution. I upgraded to a new development machine some months ago, running Windows 10 with version 7.10.3 of the GHC and 1.22.3.0 of the cabal library with 1.22.4.0 of cabal-install. I have installed version 0.9.8.0 of snap-core and version 0.9.5.1 of snap-server.
When I try and build my application in this environment, it get the following error:
Could not find module `Snap.Internal.Http.Server.Exception'
Perhaps you meant
Snap.Internal.Http.Server.Backend
Snap.Internal.Http.Server.Config
Snap.Internal.Http.Server.Date
I cannot find this module in Hackage. Did something change in Snap since I last built this code? Please, any advice will be appreciated.
Dave
P.S. Here are links to the output of the ghc-pkg list command and to the cabal file for this project.
http://zelda.designacourse.com/dave/ghc-pkg_list.txt
http://zelda.designacourse.com/dave/PreviewWrapper.cabal

With the help of, and gratitude to, epsilonhalbe we found a solution to this problem. I still do not know why the import of Snap.Internal.Http.Server.Exception started to throw an error from the compiler. However, removing that import and adding a type declaration to the variable now allows the code to build without error. i.e. catch ((_ :: IOException) -> return True).

Related

Can not load a file that uses standard libraries in haskell

Hi I use GHCI and can normally load my files. Now I need to load a file that uses random. I get this error.
Chatterbot.hs:3:1: error:
Could not find module ‘System.Random’
Use -v to see a list of the files searched for.
|
3 | import System.Random
| ^^^^^^^^^^^^^^^^^^^^
This is very weird since it works for my friend who also have just installed GHCI and did nothing other than me. The main difference is that I am on windows. I really don t understand this and have tried googling a bit and many people speak about stack but it seems annoying and It obviously works for my friend without it.
Thanks in advance
EDIT problem solved. I needed to update cabal then I ran cabal install random and it worked well. Thanks everyone for the help!
If you are using a version of cabal-install >= 3.0 (check with cabal --version), then, instead of creating a cabal package, you can move to an empty folder and type:
cabal install --lib --package-env . random
This creates a .ghc.environment file in the folder. ghci sessions started inside that folder will pick it up, and they will be able to import System.Random.
If that works correctly, you might want to install "random" globally so that any invocation of ghci can use it:
cabal install --lib random
This creates/modifies the global environment file located at ~/.ghc/$ARCH-$OS-$GHCVER/environments/default.
The System.Random module is part of the random package, not of the base package. You thus should install it. If you for example use cabal, you can install it with cabal install random.
If you use Haskell stack for example, you can add it to your package-name.cabal file:
-- …
build-depends:
base >=4.7 && <5
, random >=1.0 && <2

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.

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.

Haskell Could not find module `System'

I'm new with Haskell and have trouble with its package.
I want to import System.Random but
Could not find module `System.Random'
Then I tried to import System but
Could not find module `System'.
It is a member of the hidden package `haskell98-2.0.0.0'.
I tried to search this problem, but those solutions still don't work.
As this said, I tried to install cabal on my Mac OS X using MacPort, but
Error: The following dependencies were not installed: ghc
Error: Status 1 encountered during processing.
I have installed Haskell Platform and can use ghci in command-line.
GHCi, version 7.2.1
Then I tried to use ghc-pkg expose haskell98-2.0.0.0 as this one says.
But this time, I can't even run ghci.
Top level:
Ambiguous interface for `Prelude':
it was found in multiple packages: base haskell98-2.0.0.0
So, what can I do without using cabal?
The System.Random module belongs to the random package, which is no longer included with GHC as of version 7.2.1.
I'm not sure what to do about your Cabal problem, as I'm not familiar with Mac OS X, but I'd recommend getting that to work first. Installing random should then be trivial using Cabal.
As a possible workaround, you might want to consider using an older version of GHC.
the cabal incantation:
cabal install random
The answer here is a little bit dated and would lead to a global install and should be discouraged.
A better approach will be to add the random package as dependency in the .cabal file.
Something like this:
build-depends: base ^>=4.13.0.0 --base package
, random -- random package where System.Random can be found
cabal repl -b random # -b is short for --build-depends
This answer was based on another stackoverflow thread here. Basically it installs the package random as a dependency of your project rather than installing it globally. Packages are installed globally if you just write cabal install random - which we dont usally want.

Resources