Search code examples
haskellcabal-install

What is a Cabal 'world' file for?


What is the role of the ~/.cabal/world file, and what do its contents mean? I can't find any documentation and am confused by what I see there.

For example, it corresponds to nether the packages in my user database nor my global packages database, and while it seems to list only (a few of) the packages in my user database, it lists some that I've "removed" with ghc-pkg unregister.


Solution

  • As far as I'm aware, it's automatically populated with any package you ever explicitly requested (thus including failed installs). This means that if you copy it to another machine, you can do

    cabal install world 
    

    to aim at replicating your current setup.

    Of course, you can deregister a package behind cabal's back, and it won't know to delete it from your world file.

    (Dependencies will be installed too, but I should emphasise that hackage will have moved on in the meanwhile, and that if you want reproducible installation, it's probably easier to use the stack tool, which has that as one of its principal design goals.)