Skip to content

Links with absolute paths in --haddock #4971

@pbrisbin

Description

@pbrisbin

General summary/comments (optional)

Prior to stack-2, stack build --haddock would produce HTML files with relative links. This made it simple to (e.g.) aws s3 sync to serve the documentation, and also worked when viewing the files locally.

Since stack-2, I get absolute filesystem paths in all the links:

<a href="/home/patrick/code/project/.stack-work/.../doc/...">

This still works locally, but won't work when served.

I've looked through the documentation for Stack and Haddock (specifically --source-base and friends) but nothing I try will recover the old behavior.

My general question is, does anyone know how to get relative links back? For now, I'm resorting to seding them out before uploading.

CAVEAT: I'm only 90% sure this is a stack-2 thing. I don't refresh my documentation super frequently so it's possible it worked on an old resolver/GHC/haddock and is breaking on a newer one, but I believe it was the upgrade to stack-2 that did it. Apologies in advance if I'm incorrect. This has been confirmed below.

Steps to reproduce

  1. Have an S3 bucket as a website to serve documentation from

  2. Run something like:

    stack build --haddock
    aws s3 sync --acl public-read --delete \
      "$(stack path --local-doc-root)"/ \
      s3://{BUCKET}/{PREFIX}/

Expected

Links from the main S3 website should work (because they are relative).

Actual

Links do not work because they include /home/$USER/blah/blah in them.

Stack version

$ stack --version
Version 2.1.3, Git revision 636e3a759d51127df2b62f90772def126cdf6d1f (7735 commits) x86_64 hpack-0.31.2

Method of installation

https://aur.archlinux.org/packages/stack-static/, which packages the official binary for Arch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions