Installing a package with cabal doesn't work (random) - haskell

I'm using Windows 10. I downloaded Cabal.exe, put it in my ghc-8.8.1\bin\ directory and ran it with command cabal update. It did nothing for a while, then it ended without any messages.
Now when I run cabal install random (trying to install package "random"), I get the following error:
cabal: Error: Could not find module: System.Random with any suffix:
["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the
module is autogenerated it should be added to 'autogen-modules'.
I have no clue why it does this.
I also tried installing the package manually (following the steps from here) - downloaded package random-1.1.tar.gz and ran:
cd filepathtopackage
c:\Program Files\Apps\ghc-8.8.1\bin\runhaskell.exe Setup configure
This for a change gives me the following error:
| C:\Program Files\Apps\ghc-8.8.1\lib\Cabal-3.0.0.0\HSCabal-3.0.0.0.o: unknown symbol '.file'
Setup: Setup: unable to load package 'Cabal-3.0.0.0'
When I run ghc-pkg list, Cabal is in there, so again, no clue why it does this.
Does anyone have any tips on how to resolve this?

Related

ghc.exe: unable to load package <package_name>

I have recently started learning haskell and have never used the cabal package manager before. I'm currently working on a project that requires me to user the io-streams package.
I of course already have the Haskell Platform installed on my machine. I am currently using the x86_64-core version 8.4.3 installer.
Using a Git Bash terminal on Windows 10, I have created a .cabal-sandbox/ folder (using the cabal sandbox init command), in which to house all of my downloaded packages. I have then run cabal install io-streams to download and install the package from the Hackage site. This has worked fine.
I have now come to writing my code. This is as follows:
module StreamFiles where
import System.IO.Streams.File
main:: IO ()
main = do
putStrLn "some text here"
However, when I come to run this, using the following steps:
1. Run the cabal repl command in the directory where the .cabal-sandbox/ folder is located.
2. I then run the following in Powershell:
Prelude> :l src/fileStreaming/streamfile.hs
[1 of 1] Compiling StreamFile ( src\fileStreaming\streamfile.hs, interpreted )
Ok, one module loaded.
*StreamFile> main
And get the following error:
ghc.exe: | C:\Users\UserName\source\repos\complexHaskell\.cabal-sandbox\x86_64-windows-ghc-8.4.3\network-3.0.1.0-HkosMKsQUp05NPIgp4K8kv\HSnetwork-3.0.1.0-HkosMKsQUp05NPIgp4K8kv.o: unknown symbol `if_nametoindex'
ghc.exe: unable to load package `network-3.0.1.0'
And I cannot work out why. Is this a package problem or is there a step that I have missed when pulling the packages down from the Hackage site?
Do I need to create a .cabal file using the cabal init command and require some dependencies for my imports in there??
Thanks in advance.
C.

Can not find module after installing it

I am trying to install "threepenny-gui", I simply do it by
cabal install threepenny-gui
It is a school project that I have to use it and you can find the start code here.
After I have installed it and run Calculator.hs without changing anything I get the error
ThreepennyPages.hs:13:18:
Could not find module ‘Data.Aeson’
Perhaps you meant Data.Version (from base-4.8.2.0)
Use -v to see a list of the files searched for.
ThreepennyPictures.hs:17:18:
Could not find module ‘Graphics.UI.Threepenny’
Use -v to see a list of the files searched for.
ThreepennyPictures.hs:18:8:
Could not find module ‘Graphics.UI.Threepenny.Core’
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
I read here in section 4.1 that
This happens when you install a package globally, and the previous packages were installed locally.
But does not give any real solution. How should I install it correctly? Have been having similar problems when installing other modules.

IntelliJ Haskell plugin: ghc-modi failed with error

I just installed IntelliJ idea and the official Haskell plugin.
IntelliJ couldn't find ghc-modi.exe, so I installed ghc-mod through cabal.
However, after importing my cabal project, I am still receiving the following error:
ghc-modi failed with error: NG BUG: GMECabalFlags (GMEString "extractField: failed extracting configFlags from input, input contained `configFlags'? False")
How can I solve or get more information on this error?
Thanks in advance.
This question has been answered by Atsky on GitHub:
This is internal problem of ghc-mod. It fails to read file dist/setup-config for some reason.
Try to remove dist folder from your project and then run cabal config.

Installing Cabal has missing modules

My ghc install was out of date so I decided to reinstall ghc and cabal to hopefully fix some problems. I started out following the steps here. GHC is now version 7.8.3.
I then removed ~/.cabal and tried to install using the steps but it fails. So I removed .cabal again and tried the steps here but when I run sh bootstrap.sh it runs into missing modules:
Using local tarball for parsec-3.1.6.
[1 of 1] Compiling Main ( Setup.hs, Setup.o )
Linking Setup ...
Configuring parsec-3.1.6...
Building parsec-3.1.6...
Preprocessing library parsec-3.1.6...
Text/Parsec/Prim.hs:80:8:
Could not find module ‘Control.Monad.Trans’
There are files missing in the ‘mtl-2.2.1’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Text/Parsec/Prim.hs:81:8:
Could not find module ‘Control.Monad.Identity’
There are files missing in the ‘mtl-2.2.1’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Text/Parsec/Prim.hs:83:8:
Could not find module ‘Control.Monad.Reader.Class’
There are files missing in the ‘mtl-2.2.1’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Text/Parsec/Prim.hs:84:8:
Could not find module ‘Control.Monad.State.Class’
There are files missing in the ‘mtl-2.2.1’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Text/Parsec/Prim.hs:85:8:
Could not find module ‘Control.Monad.Cont.Class’
There are files missing in the ‘mtl-2.2.1’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Text/Parsec/Prim.hs:86:8:
Could not find module ‘Control.Monad.Error.Class’
There are files missing in the ‘mtl-2.2.1’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Text/Parsec/Text.hs:19:18:
Could not find module ‘Data.Text’
There are files missing in the ‘text-1.2.0.0’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Text/Parsec/Text/Lazy.hs:19:18:
Could not find module ‘Data.Text.Lazy’
There are files missing in the ‘text-1.2.0.0’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
Error during cabal-install bootstrap:
Building the parsec package failed.
When I run ghc-pkg check I get a WHOLE lot of stuff like this:
cannot find any of ["libHSOpenGLRaw-1.5.0.0.a","libHSOpenGLRaw-1.5.0.0.p_a","libHSOpenGLRaw-1.5.0.0-ghc7.8.3.so","libHSOpenGLRaw-1.5.0.0-ghc7.8.3.dylib","HSOpenGLRaw-1.5.0.0-ghc7.8.3.dll"] on library path
Warning: haddock-interfaces: /usr/local/share/doc/x86_64-linux-ghc-7.8.3/Cabal-1.21.1.0/html/Cabal.haddock doesn't exist or isn't a file
Warning: haddock-html: /usr/local/share/doc/x86_64-linux-ghc-7.8.3/Cabal-1.21.1.0/html doesn't exist or isn't a directory
and then this:
The following packages are broken, either because they have a problem
listed above, or because they depend on a broken package.
text-1.1.0.1
Cabal-1.20.0.2
zlib-0.5.4.1
contravariant-1.2
void-0.6.1
netwire-5.0.0
semigroups-0.15.3
unordered-containers-0.2.5.0
transformers-compat-0.3.3.4
exceptions-0.6.1
MonadRandom-0.3
mtl-2.2.1
transformers-0.4.1.0
cpphs-1.18.5
polyparse-1.9
nats-0.2
hashable-1.2.2.0
OpenGL-2.9.2.0
text-1.2.0.0
tagged-0.7.2
stb-image-0.2.1
split-0.2.2
reflection-1.5.1
random-1.0.1.1
primitive-0.5.3.0
prelude-extras-0.4
parallel-3.2.0.4
bitmap-0.0.2
bindings-DSL-1.0.21
GLURaw-1.4.0.1
OpenGLRaw-1.5.0.0
You can either use ghc-pkg unregister on each of the broken packages to clean them out properly, or possibly blow away the whole ~/.ghc folder and start again. You may need to use --force to avoid having to respect the dependency order of the packages.
Did you also remove ~/.ghc when you removed ~/.cabal? If not, I suggest you try that, since if I understand correctly, the first may contain references to packages installed in the second.

install yesod with stackage failed

environment:
ubuntu14.04
haskell platform 2014 2.0.0 (ghc 7.8.3,cabal 1.18.13)
stackage:Stackage build for GHC 7.8 + Haskell Platform, 2014-09-24, exclusive
according to http://www.yesodweb.com/page/quickstart , I ran:
dsu#dsu-G41MT-D3:~$ cabal install alex happy yesod-bin
Resolving dependencies...
Configuring ansi-terminal-0.6.1.1...
Configuring alex-3.1.3...
Downloading unix-time-0.3.4...
Failed to install ansi-terminal-0.6.1.1
Last 10 lines of the build log ( /home/dsu/.cabal/logs/ansi-terminal-0.6.1.1.log ):
Configuring asn1-types-0.2.3...
Configuring auto-update-0.1.1.3...
Failed to install alex-3.1.3
Last 10 lines of the build log ( /home/dsu/.cabal/logs/alex-3.1.3.log ):
Failed to install asn1-types-0.2.3
Configuring base-unicode-symbols-0.2.2.4...
Last 10 lines of the build log ( /home/dsu/.cabal/logs/asn1-types-0.2.3.log ):
Failed to install auto-update-0.1.1.3
Last 10 lines of the build log ( /home/dsu/.cabal/logs/auto-update-0.1.1.3.log ):
Configuring base64-bytestring-1.0.0.1...
Configuring blaze-builder-0.3.3.4...
Failed to install base-unicode-symbols-0.2.2.4
Last 10 lines of the build log ( /home/dsu/.cabal/logs/base-unicode-symbols-0.2.2.4.log ):
Failed to install unix-time-0.3.4
Last 10 lines of the build log ( /home/dsu/.cabal/logs/unix-time-0.3.4.log ):
cabal: /home/dsu/.cabal/logs/unix-time-0.3.4.log: does not exist
It simply says "fail to install" and give no any hints.Why use of stackage still has these problems?
This generic cabal debugging advice usually finds the problem....
Update the cabal database, try again
cabal update
cabal install ....
Try to install the dependency with the problem separately.... Looking above, it seems I see a few lines that start with "Failed to install....", test these separately.
cabal install base-unicode-symbols
Recurse if necessary.
Download the package that fails,
cabal unpack base-unicode-symbols
cd base-unicode-symbols-*
Configure to see if its dependencies are all loaded
cabal configure
If not, recurse into the troubled package.
Try to build the package
cabal build
If it doesn't work, you now have useful error messages. If you can fix the problem, great, else repost the information here.
Install
cabal install
In more drastic cases, you might want to delete (actually, just move it in case you want it back) your ~/.cabal/* contents, or your ~/.ghc/* contents, but leave this as a last resort, because you will have to reinstall all cabal packages. Also, you might want to keep the contents of ~/.cabal/bin/*.
I just updated Stackage Server to use FP Complete's Hackage mirror (which is Amazon S3 powered) instead of Hackage itself. That should make it completely resilient to Hackage downtime. Thanks for raising this issue, we definitely want Stackage to have better uptime guarantees than Hackage.
I've encountered the same problem. I have resolved it by temporarily deleting my HTTP_PROXY environment variable to not have cabal try to connect through an unreachable server.

Resources