install --builddir

Duncan Coutts duncan.coutts at
Mon Apr 15 16:52:44 CEST 2013

On Tue, 2013-04-09 at 08:46 -0400, Benjamin Scarlet wrote:
> I'm having trouble with install --builddir.
> If I run
> $ cabal install --builddir /some/absolute/path test-framework
> I get an error after regex-posix is installed, during the build of test-framework:
> Text/Regex/Posix/Wrap.hsc:141:8:
>    Could not find module `Text.Regex.Base.RegexLike'
>    It is a member of the hidden package `regex-base-0.93.2'.
>    Perhaps you need to add `regex-base' to the build-depends in your .cabal file.
>    Use -v to see a list of the files searched for.
> But if I run
> $ cabal install --builddir /some/absolute/path regex-posix
> $ rm -r /some/absolute/path
> $ cabal install --builddir /some/absolute/path test-framework
> I do not get the error. Between experiments I'm removing my ~/.cabal and ~/.ghc and running cabal update.
> Naively, it looks to me like using an absolute builddir has changed
> things so successive packages share the same intermediate files, which
> in turn has caused a later package to erroneously recompile a
> previously generated file.

I'm sure that's exactly what is going on. It is using that directory to
store the build artefacts and that is not supposed to be shared with any
other package.

> My ultimate aim is only to be able to use cabal-dev for my development
> builds, but without writing into my source tree. Is there any way to
> specify a build directory outside the source of a package without it
> winding up shared? Could/should cabal instead create a separate
> subdirectory within the specified builddir for each package to be
> built, so that specifying an external location didn't break things?

You could just call it with builddir set to a fresh directory (e.g. with
a wrapper script like cabal-dev). If you want to set it statically and
with a shared location then perhaps we could do something like allow
vars in the builddir, like we allow vars in the install dirs. A patch to
do that shouldn't be too difficult if you'd like to have a go. See the
InstallDirs and path template stuff


More information about the cabal-devel mailing list