15

How can I generate and install documentation for all locally installed cabal packages? I turned on the documentation flag in ~/.cabal/config which means that all newly installed packages will have documentation also generated. But how to generate documentation for all already installed packages?

Is there a way to automatically cabal install --reinstall all already installed packages? And more importantly, is that a good idea?

Anupam Jain
  • 7,851
  • 2
  • 39
  • 74

3 Answers3

4

If you have a recent-ish version of cabal-install (>= 0.10, I think), you can try doing

$ cabal install --reinstall --upgrade-dependencies world

Unfortunately, it didn't work in my case:

$ cabal install --dry-run --reinstall world
Resolving dependencies...
cabal: cannot configure Agda-2.2.10. It requires haskell-src-exts >=1.9.6 &&
<1.10
For the dependency on haskell-src-exts >=1.9.6 && <1.10 there are these
packages: haskell-src-exts-1.9.6. However none of them are available.
haskell-src-exts-1.9.6 was excluded because haskell-src-exts-1.11.1 was
selected instead
haskell-src-exts-1.9.6 was excluded because hlint-1.8.12 requires
haskell-src-exts ==1.11.*

If you bump into an error like this, you can try manually editing the ~/.cabal/world file.

Mikhail Glushenkov
  • 14,928
  • 3
  • 52
  • 65
  • That worked! Not perfectly.. But almost. It did not get all the dependencies of all the packages and the generated docs do not have a proper index or links to sources but it's a great improvement over not having any local docs at all. Thanks! – Anupam Jain Jul 04 '11 at 08:36
  • Yes, the world file lists only manually installed packages, so the automatically installed dependencies are not reinstalled (unless there's a new version on Hackage). – Mikhail Glushenkov Jul 04 '11 at 09:49
  • @monadic Thanks, fixed. I was thinking about Cabal version. – Mikhail Glushenkov Jul 04 '11 at 12:13
3

Please note that cabal install --only-dep --reinstall does not work.

If you are using a sandbox, you can do

cabal sandbox delete
cabal sandbox init
cabal install -j --only-dep --enable-documentation

The -j option allows it to build in parallel.

ryantm
  • 8,217
  • 6
  • 45
  • 57
-1

You could try something like this in bash.

for pkg in `ghc-pkg list --simple`
do
cabal install $pkg --reinstall
done

But I really don't know, whether it's a good idea.

ryantm
  • 8,217
  • 6
  • 45
  • 57
hal
  • 305
  • 2
  • 6