Duncan Coutts duncan.coutts at worc.ox.ac.uk
Wed Apr 22 18:43:10 EDT 2009

```On Wed, 2009-04-22 at 11:52 +0100, Neil Mitchell wrote:

> >> How come it's picking up a different haddock? Is that an error with
> >> the findExecutable, or is it deliberately trying to pick a newer
> >> version?
> >
> > It's not looking for a newer version. It's looking for the first version
> > that is on the Windows %PATH% env var.

> C:\ghc\ghc-6.10.2\bin (and probably 6.8.3 as well). Is Cabal searching
> the path in the right order?

For the record: it turns out that the answer is no. This is because the
Win32 SearchPath function doesn't just search the %PATH%, it searches
the directory containing the .exe of the currently running process, the
current directory, the windows and system directories and finally it
searches the %PATH%.

So in this example, the cabal.exe program is in C:\Program Files\Haskell
\bin and so Windows looks there first for haddock.exe despite the fact
that C:\ghc\ghc-6.10.2\bin is earlier on the %PATH%.

The workaround therefore is to get rid of a duplicate haddock or to
specify the one to use explicitly. The ticket for a nicer solution is