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

2

6

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.

Burnisher answered 17/11, 2011 at 10:42 Comment(0)
R
11

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.

Recriminate answered 17/11, 2011 at 11:44 Comment(1)
Thanks, I was aware of that but it seemed from RWH that you need parsec and network installed first (book.realworldhaskell.org/read/…), and from the docs HTTP installed first before you can run bootstrap.sh. I see now bootstrap.sh does all that for you. That's what I get for doing this at 3am.Burnisher
N
6

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.

Nan answered 17/11, 2011 at 10:47 Comment(1)
Thanks, I see i was using runhaskell Setup incorrectly. Not firing on all cylinders at 3am. Much appreciated!Burnisher

© 2022 - 2024 — McMap. All rights reserved.