Cabal/How to install a Cabal package remotely

From HaskellWiki

[WARNING: This page is *extremely* out of date and likely to be obsolete]

Installing Haskell packages on a remote server[edit]

Sometimes, it is difficult or inconvenient to set up the entire build environment that Cabal needs to install packages on a remote server.

For example, suppose you want to install a package on a hosted virtual server. You may find it much easier to get just a working GHC compiler installed than to get an entire usable Cabal build system set up. Here is one person's experience trying to use Cabal to set up Haskell packages on Dreamhost in October, 2009.

As an alternative, you can build Haskell packages on a local computer, then upload the built packages to the server. The basic method is to build the package using manual Cabal commands, use cabal copy to create the files to be installed, upload those files to the server, and register the package to GHC.

Below is a summary of the steps needed:

  1. Set up an environment that mimics the build environment on the remote server. For example:
    • If the architecture and operating system on the local computer are identical to those on the server, you may be able to use the local computer as is.
    • If the architecture and operating system on the local computer are similar to those on the server, you may be able to use a chroot jail.
    • You may need to use virtualization to run the operating system of the remote server on the local computer.
  2. Make sure that GHC and cabal - the exact same version as on the remote server - are available.
  3. Create a temporary working directory - we'll call it $WORKDIR.
  4. Create a subdirectory $WORKDIR/image.
  5. cd $WORKDIR
  6. cabal fetch <package>
  7. cabal unpack <package> This creates a package subdirectory that contains the files from the package.
  8. cd <package subdirectory>
  9. cabal configure with options that are needed for the remote server. For example, you may need --libdir=... --bindir=... --global. See the Cabal documentation, or run cabal configure --help, for more options that you may need to set.
  10. cabal build
  11. cabal copy --destdir=../image This creates the files that you will upload and install on the remote server.
  12. cabal register --gen-pkg-config=../pkg.conf This creates the file that you will use to register the package on the remote server.
  13. Upload the files created in the $WORKDIR/image directory to the remote server, and install them in their proper places on the remote server.
  14. Upload $WORKDIR/pkg.conf to your home directory on the remote server.
  15. On the remote server, in your home directory, type: ghc-pkg register pkg.conf