commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
4k stars 843 forks source link

Allow specify `haddock` executable #3100

Open Fuuzetsu opened 7 years ago

Fuuzetsu commented 7 years ago

General summary/comments (optional)

I'm trying very hard to get stack to use a patched version of haddock. There is no flag that I can find which allows me to do this. stack build haddock with haddock in local dependencies seems to do the right thing but then stack build walks all over it. I do not see any way to pass through --with-haddock to configure phase or any other usual tricks.

Steps to reproduce

In stack.yaml I have the following which is a monkey-patched version of Haddock (2.17.3.1.1).

- location:
   git: https://github.com/haskell/haddock
   commit: acc39ee9e31895bec2c3c56b5e783875523758da
  extra-dep: true
  subdirs:
  - '.'
  - haddock-api
$ stack --nix --no-nix-pure build haddock
ghc-paths-0.1.0.9: configure
ghc-paths-0.1.0.9: build
haddock-library-1.4.2: configure
ghc-paths-0.1.0.9: copy/register
haddock-library-1.4.2: build
haddock-library-1.4.2: copy/register
haddock-api-2.17.3.1.1: configure (lib)
haddock-api-2.17.3.1.1: build (lib)
haddock-api-2.17.3.1.1: copy/register
haddock-2.17.3.1.1: configure (exe)
Configuring haddock-2.17.3.1.1...
haddock-2.17.3.1.1: build (exe)
Preprocessing executable 'haddock' for haddock-2.17.3.1.1...
[1 of 2] Compiling ResponseFile     ( driver/ResponseFile.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/haddock/haddock-tmp/ResponseFile.o )
[2 of 2] Compiling Main             ( driver/Main.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/haddock/haddock-tmp/Main.o )
Linking .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/haddock/haddock ...

Warning: The following modules should be added to exposed-modules or other-modules in /home/shana/programming/…/.stack-work/downloaded/5g6pXrlHUwpq/haddock.cabal:
    - In haddock component:
        ResponseFile

Missing modules in the cabal file are likely to cause undefined reference errors from the linker, along with other problems.
haddock-2.17.3.1.1: copy/register
Installing executable(s) in
Warning: Unable to strip executable or library 'haddock' (missing the 'strip'
/home/shana/programming/…/.stack-work/install/x86_64-linux-nix/lts-8.2/8.0.2/bin
program)     
Completed 4 action(s).

$ stack --nix --no-nix-pure exec -- which -a haddock
/home/shana/programming/…/.stack-work/install/x86_64-linux-nix/lts-8.2/8.0.2/bin/haddock
/nix/store/9m6wdczvj0py4y0q92ychpva76nasgla-ghc-8.0.2/bin/haddock

$ stack --nix --no-nix-pure exec -- haddock --version
Haddock version 2.17.3.1.1, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008

As you can see exec picks the right version. I have this setup on a jenkins machine but there (slightly anonymised)

jenkins@…$ stack exec -- which haddock
/var/lib/jenkins/…/.stack-work/install/x86_64-linux/lts-8.2/8.0.2/bin/haddock
jenkins@…$ stack exec -- which -a haddock
/var/lib/jenkins/…/.stack-work/install/x86_64-linux/lts-8.2/8.0.2/bin/haddock
/var/lib/jenkins/.stack/programs/x86_64-linux/ghc-8.0.2/bin/haddock
jenkins@…$ stack exec -- bash -c 'echo $PATH'
/var/lib/jenkins/…/.stack-work/install/x86_64-linux/lts-8.2/8.0.2/bin:/var/lib/jenkins/.stack/snapshots/x86_64-linux/lts-8.2/8.0.2/bin:/var/lib/jenkins/.stack/programs/x86_64-linux/ghc-8.0.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
jenkins@…$ stack exec -- haddock --version
Haddock version 2.17.3.1.1, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008

Expected

Given the output of the above, when stack goes on to call haddock, I would expect my locally built 2.17.3.1.1 be used, not some system one.

Actual

2017-03-31 12:28:12.545754: [debug] Run process: /var/lib/jenkins/.stack/programs/x86_64-linux/ghc-8.0.2/bin/haddock --hyperlinked-source
@(System/Process/Read.hs:306:3)

Why oh why?! And yes, it builds and sees the "right" version

+ stack build haddock
+ stack exec -- haddock --version
Haddock version 2.17.3.1.1, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008
+ stack build --bench --no-run-tests --no-run-benchmarks --ghc-options=-eventlog --haddock --no-haddock-deps -v

but then during very next step it uses the system version (and build fails because that Haddock is unpatched).

Stack version

$ stack --version
Version 1.4.0 x86_64

jenkins@…$ stack --version
Version 1.3.2, Git revision 3f675146590da4f3edf768b89355f798229da2a5 (4395 commits) x86_64 hpack-0.15.0

Method of installation

mpilgrem commented 8 months ago

@Fuuzetsu, I am working through issues - including ones raised some time ago. With the current version of Stack, it looks for haddock in the same directory as the directory containing the specified GHC executable.

Consequently, I have rephrased your issue as a feature request.