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?
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.
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.
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.
Related
I try to install "System.Random" by cabal through Powershell & Git Bash.
getting this result.
PS C:\Users\xxx> cabal install random
Resolving dependencies...
Up to date
Warning: You asked to install executables, but there are no executables in
target: random. Perhaps you want to use --lib to install libraries instead.
And then I try to input like this
cabal install --lib random
Resolving dependencies...
and
cabal install random --lib
both output Resolving dependencies... Up to date without warning.
but ghci Could not find module `System.Random'
input cabal install random still having the same result with warning.
It is a bad idea to install packages globally, so cabal install doesn't do that. The package is built and placed into the Cabal package database, but GHC won't find it unless you specifically tell Cabal to point GHC at it:
cabal repl -b random # -b is short for --build-depends
# Note that cabal install isn't really necessary: the above command would have installed random if it wasn't there already
I think your Cabal/GHC installation might be outdated, however. When you do cabal install --lib random, recent versions of Cabal should write out an "environment file" at %APPDATA%\ghc\arch-os-ghcversion\environments\default, which GHC should then automatically read (GHCi should say something like Loaded package environment from ...), and it should then find the installed package. If you are using the latest version of everything,
cabal install --lib random
ghci
should work.
If I install a package using cabal install pkg then cabal will install all packages that pkg depends on. If there is a conflict with already installed packages then cabal shows which packages have to be installed freshly, which ones are updated and which installed ones will be broken.
Is there a way to get this list unconditionally instead of running the install procedure?
cabal install <pkg> --dry-run will print the packages that will be installed without actually performing any of the installation. It will not show this information though if the package is installed or similar.
I want to compile my program with profiling, so I run:
$ cabal configure --enable-executable-profiling
...
$ cabal build
...
Could not find module 'Graphics.UI.GLUT':
Perhaps you havent installed the profiling libraries for package 'GLUT-2.2.2.0'?
...
$ # indeed I have not installed the prof libs for GLUT, so..
$ cabal install -p GLUT --reinstall
...
Could not find module 'Graphics.Rendering.OpenGL':
Perhaps you havent installed the profiling libraries for package 'OpenGL-2.4.0.1'?
...
So, the problem is, that unlike cabal's usual welcome behavior, cabal doesn't resolve the dependencies and install them when needing profiling libraries.
I can work around it by resolving the dependencies manually (by following errors that appear after a while of compiling):
$ cabal install -p OpenGLRaw --reinstall
$ cabal install -p StateVar --reinstall
$ cabal install -p Tensor --reinstall
$ cabal install -p ObjectName --reinstall
$ cabal install -p GLURaw --reinstall
$ cabal install -p OpenGL --reinstall
$ cabal install -p GLUT --reinstall
And then repeat for my next dependency..
Is there a better way to do this? i.e do make cabal do the work on its own as it does for normal libraries?
I've enabled library-profiling: True in my ~/.cabal/config file. From then on, any new installations will automatically enable profiling.
Unfortunately that still means I had to manually reinstall for the old packages already installed. Although, after a while of doing this manually, I now have most packages reinstalled with profiling enabled...
From a comment by Tom Lokhorst:
I do hope someone will come along with a better answer, one that would not require me to reinstall the complete Haskell Platform manually next time.
For future visitors:
The task of installing profiling versions of all installed libraries has become less of a chore, cabal (cabal-install) now keeps track of what was installed using it in the world file in the .cabal directory (on linux, that would be $HOME/.cabal, on Windows something like C:\Users\%YOU%\AppData\Roaming\cabal\, on OSX ??).
So after enabling profiling in the config file (in the same directory), and clearing GHC's package database (you can find the locations of the global and user db per ghc-pkg list nonexisting; remove the cabal-installed packages from the global database with ghc-pkg unregister packagename if you have any, rename or delete the entire user db - this is necessary because the world file only tracks explicitly installed packages, not their dependencies), installing everything with profiling support should work as follows:
$ cabal install --reinstall world --dry-run
First run with --dry-run to check for problems before actually reinstalling anything. If it would reinstall boot packages like process or directory, that's a bad sign, if you don't know how to handle it, ask on the #haskell IRC channel, one of the mailing lists, or here for guidance. If it fails to find a consistent install plan due to new versions on hackage of some packages which are incompatible with each other, that can usually be solved by editing the world file and constraining allowable versions of some packages.
Then, if you are optimistic that nothing will badly break,
$ cabal install --reinstall world
and have a nice pot of tea while GHC is busy compiling.
Daniel Fischer's answer looks good, but for some reason my ~/.cabal/world library only contained entries for libraries directly installed, and not their dependencies.
Instead, I dumped out a list of all installed libraries using
$ ghc-pkg list > list
This lists the libraries installed system-wide and locally. Therefore, I edited the list file to remove the first portion (containing libraries installed system-wide) leaving only the lines after /home/<user>/.ghc/.... Finally, I ran
$ cabal install --reinstall $(cat list)
This worked for me. You should maybe do --dry-run first. Then go make a pot of tea. Or bake a cake.
it appears there is no way right now: Ticket #282 - profiling versions of libraries not managed well "As usual the problem is lack of devevloper time to implement all these
nice features we all want."
For visitors 2016+: Just install ghc-prof
Debian Linux Systems:
sudo apt-get install ghc-prof
Arch Linux Systems:
sudo pacman -S ghc-prof
I'm trying to set up Haskell from scratch, on Ubuntu 11.04, without using the outdated Debian repository or Haskell-Platform.
I've installed GHC-7.0.4 from source with no problem, and now need to install Cabal (which appears to already be included in GHC in /usr/local/lib/ghc-7.0.4/Cabal-1.10.2.0) and Cabal Install.
The latter specifies several dependencies (parsec and network), each of which has several dependencies of their own (mtl, text, etc).
What's the command to install these packages, that I downloaded from hackage in tar.gz form?
Unpack, then runhaskell doesn't work.
I see Setup.lhs, but it's not clear what that's for or how to use it.
Most of the Haskell documentation I've found assumes you've installed from a repo or Haskell-Package and doesn't really explain this well.
cabal-install has a shell script that does this. If you download it from hackage and install it, you can start bootstrap.sh to install cabal-install. You can then use it to install other packages.
There are two different packages: Cabal and cabal-install. Cabal is a library, and cabal-install is an executable named cabal.
To install a package, cabal-install is an optional convenience wrapper around Cabal, but Cabal is required.
According to http://hackage.haskell.org/trac/ghc/wiki/Commentary/Libraries , Cabal is a 'zero-boot' package, so when you build GHC, Cabal and its dependencies are built for you automatically.
You can use ghc-pkg executable to check which packages are already installed:
# ghc-pkg list
Check if Cabal is in the list after you build GHC. If yes, you can install more packages without cabal-install using this documentation:
http://haskell.org/haskellwiki/Cabal/How_to_install_a_Cabal_package
I suggest you to install cabal-install first, and then install everything else using cabal-install executable. A usual commandine for global installation is this:
# runhaskell Setup configure
# runhaskell Setup build
# sudo runhaskell Setup install
Unpack a package tarball and run the commands in the folder with Setup.hs or Setup.lhs files. Note that a per-user non-root installation is also supported - Use runhaskell Setup configure --user
When you install cabal executable and its dependencies this way, use cabal install {package-name} to install more packages.
Note that Haskell Platform exists mostly because of the pain of installing cabal-install by yourself.
I want to compile my program with profiling, so I run:
$ cabal configure --enable-executable-profiling
...
$ cabal build
...
Could not find module 'Graphics.UI.GLUT':
Perhaps you havent installed the profiling libraries for package 'GLUT-2.2.2.0'?
...
$ # indeed I have not installed the prof libs for GLUT, so..
$ cabal install -p GLUT --reinstall
...
Could not find module 'Graphics.Rendering.OpenGL':
Perhaps you havent installed the profiling libraries for package 'OpenGL-2.4.0.1'?
...
So, the problem is, that unlike cabal's usual welcome behavior, cabal doesn't resolve the dependencies and install them when needing profiling libraries.
I can work around it by resolving the dependencies manually (by following errors that appear after a while of compiling):
$ cabal install -p OpenGLRaw --reinstall
$ cabal install -p StateVar --reinstall
$ cabal install -p Tensor --reinstall
$ cabal install -p ObjectName --reinstall
$ cabal install -p GLURaw --reinstall
$ cabal install -p OpenGL --reinstall
$ cabal install -p GLUT --reinstall
And then repeat for my next dependency..
Is there a better way to do this? i.e do make cabal do the work on its own as it does for normal libraries?
I've enabled library-profiling: True in my ~/.cabal/config file. From then on, any new installations will automatically enable profiling.
Unfortunately that still means I had to manually reinstall for the old packages already installed. Although, after a while of doing this manually, I now have most packages reinstalled with profiling enabled...
From a comment by Tom Lokhorst:
I do hope someone will come along with a better answer, one that would not require me to reinstall the complete Haskell Platform manually next time.
For future visitors:
The task of installing profiling versions of all installed libraries has become less of a chore, cabal (cabal-install) now keeps track of what was installed using it in the world file in the .cabal directory (on linux, that would be $HOME/.cabal, on Windows something like C:\Users\%YOU%\AppData\Roaming\cabal\, on OSX ??).
So after enabling profiling in the config file (in the same directory), and clearing GHC's package database (you can find the locations of the global and user db per ghc-pkg list nonexisting; remove the cabal-installed packages from the global database with ghc-pkg unregister packagename if you have any, rename or delete the entire user db - this is necessary because the world file only tracks explicitly installed packages, not their dependencies), installing everything with profiling support should work as follows:
$ cabal install --reinstall world --dry-run
First run with --dry-run to check for problems before actually reinstalling anything. If it would reinstall boot packages like process or directory, that's a bad sign, if you don't know how to handle it, ask on the #haskell IRC channel, one of the mailing lists, or here for guidance. If it fails to find a consistent install plan due to new versions on hackage of some packages which are incompatible with each other, that can usually be solved by editing the world file and constraining allowable versions of some packages.
Then, if you are optimistic that nothing will badly break,
$ cabal install --reinstall world
and have a nice pot of tea while GHC is busy compiling.
Daniel Fischer's answer looks good, but for some reason my ~/.cabal/world library only contained entries for libraries directly installed, and not their dependencies.
Instead, I dumped out a list of all installed libraries using
$ ghc-pkg list > list
This lists the libraries installed system-wide and locally. Therefore, I edited the list file to remove the first portion (containing libraries installed system-wide) leaving only the lines after /home/<user>/.ghc/.... Finally, I ran
$ cabal install --reinstall $(cat list)
This worked for me. You should maybe do --dry-run first. Then go make a pot of tea. Or bake a cake.
it appears there is no way right now: Ticket #282 - profiling versions of libraries not managed well "As usual the problem is lack of devevloper time to implement all these
nice features we all want."
For visitors 2016+: Just install ghc-prof
Debian Linux Systems:
sudo apt-get install ghc-prof
Arch Linux Systems:
sudo pacman -S ghc-prof