Cabal: Blocking base packages from installing - haskell

I'm using cabal-install 1.14.0 on Ubuntu 12.04, and ghc 7.4.1.
Some cabal packages I try to install are pulling in directory-1.2.0.0, which requires ghc 7.6. Is there a way to configure cabal to not even attempt to install directory-1.2.0.0?

You can use a constraint,
cabal install foo --constraint="directory < 1.2"
or, as Daniel Wagner reminded me, better, since it really prevents reinstalls,
cabal install foo --constraint="directory installed"
and if you want that globally, add that to your cabal config file (~/.cabal/config on Linux and Mac, Somewhere in \Users\You\AppData on Windows, iirc), that has a line
-- constraint:
uncomment that and add the constraint.

Related

cabal-install and ghc 7.10.1

I just upgraded to ghc 7.10.1 and whenever I try use cabal-install I run into the following error:
ghc: ghc no longer supports single-file style package databases (dist/package.conf.inplace) use 'ghc-pkg init' to create the database with the correct format.
How do I fix this?
If you are on Mac OS X and are using homebrew it may be that you installed Cabal through haskell-platform package, which is outdated with no direct upgrade path.
You should uninstall haskell-platform and reinstall Cabal using the cabal-install package.
It could well be you have a newer cabal on your path but can't find it because the old one shadows it. So looking for where cabal may help you resolve that. Barring that, you can download a newer cabal binary from the cabal homepage.

Cabal install hoogle not working

I need to configure eclipsefp and install hoogle and scion-browser for setting up a haskell project using mysql.
I tried to install hoogle and scion-browser from Eclipse -> Preference -> Helper executable, and also from the terminal, however unsuccessfully.
cabal install hoogle
and
cabal install scion-browser
fail, throwing the following:
cabal:codec.compression.zlib: premature end of compressed stream.
Edit:
It may be a problem with the cabal version?
If I run cabal --version in terminal, it says:
cabal-install version 0.14.0
using version 1.14.0 of the Cabal library
If I perform cabal update nothing happens.
However, in Eclipse -> Helper Executables there are two versions available:
version 0.14.0
version 1.18.0.2
They are located at different locations, I checked the second one to be used.
in my case, the downloaded package is broken, figured it out by running cabal install -v package-name, removed it manually and finally worked

ubuntu haskell ghci 7.4.1 could not find module "System.Random"

When I tried to load a .hs in ghci, it failed on the line:
import System.Random
Message:
Could not find module `System.Random'
Use -v to see a list of the files searched for.
I remember it worked yesterday and all of a sudden today it does not work.
This problem only occurs on Ubuntu 12.04 LTS, GHCi 7.4.1 , when i tried this on windows haskell platform and other linux machines i worked.
I tried to use
sudo apt-get remove ghc
sudo apt-get install ghc
to remove and re install ghc, but however the problem persists.
Could someone help me? Thanks
You must install the random package. You can probably get it from your package manager (as something like libghc-random-dev or similar), or you may cabal install random.
Edit in 2021 These days, cabal install is not the way. Instead, use cabal init to create a package and list random in your build-depends field. Compilation can be performed with cabal build (just build) or cabal run (to execute the result); interactive use is available via cabal repl.

Error in cabal-installing hspec

I'm trying to install hspec, but I'm getting this:
$ cabal install hspec
Resolving dependencies...
cabal: dependencies conflict: ghc-7.2.2 requires containers ==0.4.2.0 however
containers-0.4.2.0 was excluded because ghc-7.2.2 requires containers
==0.4.1.0
What does this even mean?
Also, using ghc 7.2.2, cabal 10.2.
It sounds like you somehow broke your GHC install. GHC 7.2.2 comes with containers-0.4.1.0 (the version of which is the same as for GHC 7.2.1). It might be possible to fix it, but if the global package setup is broken then it would probably be easiest to re-install GHC.
What does ghc-pkg list containers say?
If containers-0.4.2.2 is found only in the per-user install (i.e. the /home/clark/.ghc/${arch}-${os}-7.2.2/package.conf.d output), then rm'ing /home/clark/.ghc/ and re-installing all the packages you installed with cabal install will fix it.

How do you install packages/libraries without Cabal or Cabal-Install?

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.

Resources