creswick/cabal-dev

cabal-dev ignores user packages

Closed this issue · 3 comments

cabal-dev seems to be ignoring the user's package repository. This is causing me a lot of trouble with packages that can't be automatically installed, as they have to be installed by hand in each sandbox, every time it's rebuilt. The only workaround I can think of is to install them globally, which is obviously a bad idea.

I'm sorry this is causing you trouble, but this is by design. The problem with allowing the user database to be involved is that it greatly increases the chance that you won't be able to perform a consistent build. It introduces build environment state that is not easily observable during dependency resolution and will usually cause recompilations of packages installed there, potentially breaking others.

One way to get around the problem you mentioned about installing things by hand is to install them all at once, i.e.,

cabal-dev install ../foo ../bar ../baz .

This is actually the best way to do this, because this makes cabal perform dependency resolution over the entire package collection at once rather than doing it on a per-package basis, possibly causing reinstalls and breakages in the future. I recommend using this technique in your project's top-level build script to ensure that you have a sane sandbox package set.

They can't be automatically installed all at once either. The problem is packages like wx, which need binaries and environment variables set. I suppose there might be some way to do this in the sandbox, but creating a script to do this for each problematic package, and running it in every sandbox (and again after each clean), is a pain.

If this will be the only way to do it, do you have any tips for automating the installation of wx in sandboxes? (I'm doing this on Windows, where such things always seem to be harder.)

I don't have any experience with installing wx in particular, but this does come up with a wide range of packages where binary tools etc. are required in the sandbox. The process usually goes something like this:

  • PATH=$(pwd)/cabal-dev/bin:$PATH
  • cabal-dev install tool1 tool2 ... (e.g., alex, happy, etc.)
  • Set environment variables
  • cabal-dev install wx ...