Installing Cabal has missing modules - haskell

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.

Related

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

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?

Electron, TypeScript, SQLite: package.json not found

I'm having trouble using the npm sqlite3 package with electron. I'm compiling my electron app from Typescript files to Javascript, bundling them with browserify, and then running the main bundle to launch the main process.
But when I try to use sqlite3, I have problems. I've tried using electron-rebuild as its own separate step before compiling the typescript. I've tried installing sqlite3 with a --build-from-source flag. But whenever I try to run my main bundle, I get a "package.json does not exist" error, which seems to be coming from node-pre-gyp code in my main bundle, which is from the sqlite3 module.
Does anyone have any ideas as to what I'm doing wrong? I don't understand why the code is building itself again with node-pre-gyp when I already rebuilt it with electron-rebuild. I have a package.json in the root directory of the project, but the main bundle is in (root)/build/js-bundles, and the code is looking for package.json in (root)/build.
I know my description isn't all that clear, so if anything isn't obvious I'll do my best to clarify. (The program works fine when I remove the dependency on sqlite3).
Okay, so the problem is that I was using browserify to bundle the sqlite3 dependency. By excluding sqlite3 with the --exclude flag, the problem disappeared.
The issue seems to be that building sqlite3 generates a sqlite3.js file whose sole purpose is to find (and load?) the built node-sqlite3.node binary -- but only at runtime. When sqlite3 is bundled and the bundle is run, it will attempt to locate the binary, but it can't, because my bundle isn't in the node_modules/sqlite directory, it's in my build directory. By excluding sqlite3 from the browserify bundling, at run-time, the import * as sql from "sqlite3" will find node_modules/sqlite3/sqlite3.js, find the binary, and then load it into the program.
The lesson seems to be that while browserify knows how to bundle standard NodeJs modules like fs and path, bundling custom native node modules from npm doesn't work. The program has to find it at run-time.
I don't know anything about the inner workings of NodeJs and how the program knows to look for sqlite3 in build/../node_modules/sqlite3 (I didn't know that it could), so I'd be happy if anyone more knowledgeable could provide details.
Also, even after excluding sqlite3, I still had problems because I hadn't built sqlite3 against my version of electron. Resources for doing this can be found at electron-rebuild in the general case, or in the case of sqlite3, at mapbox/node-sqlite3 in the Installing section.

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.

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.

Cannot find out module Data.Colour

I cannot import module Data.Colour, and the error as follow:
Could not find module `Data.Colour'
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
Am I missing anything?
A Hayoo! search reveals that this module lives in the colour package, which you presumably don't have installed. To install it, run cabal update followed by cabal install colour.

Resources