Cabal/How to install a Cabal package remotely
[WARNING: This page is *extremely* out of date and likely to be obsolete]
Installing Haskell packages on a remote server
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:
- 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.
- Make sure that GHC and cabal - the exact same version as on the remote server - are available.
- Create a temporary working directory - we'll call it $WORKDIR.
- Create a subdirectory $WORKDIR/image.
cabal fetch <package>
cabal unpack <package>This creates a package subdirectory that contains the files from the package.
cd <package subdirectory>
cabal configurewith 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.
cabal copy --destdir=../imageThis creates the files that you will upload and install on the remote server.
cabal register --gen-pkg-config=../pkg.confThis creates the file that you will use to register the package on the remote server.
- Upload the files created in the $WORKDIR/image directory to the remote server, and install them in their proper places on the remote server.
- Upload $WORKDIR/pkg.conf to your home directory on the remote server.
- On the remote server, in your home directory, type:
ghc-pkg register pkg.conf