Search code examples
haskellcabal

Cabal: only work with checked in libraries in project directory


I would like to download all the dependencies of my cabal project to my project directory/repository and force cabal to never use ~/.cabal/ and never download any new dependency from the internet. The downloaded libraries should be system independent (not include local paths etc.). Is this possible?

The idea behind this is, to copy the project directory to another (offline) system where the same ghc is installed and it should work out of the box.


Solution

  • According to the cabal docs, you can set active-repositories: none in your cabal.project or cabal file to put cabal-install in offline mode.

    Then, you could create a cabal project and try to make all the dependencies that don't come bundled with GHC itself local packages. Clone them in your project folder and add them to the packages: section of cabal.project.


    The problem with the above is that running cabal clean would require re-compiling all packages afterwards.

    As an alternative, create a local no-index package repository in your offline machine, make it the only available package repository using active-repositories:, and put the sdist tarballs of all your dependencies there.

    That way the dependencies will only be compiled once.