commercialhaskell/stack

stack datadir option writes to datadir during build, breaking DESTDIR, unlike cabal

Opened this issue · 0 comments

I believe that this stack behavior is a bug:

Specifying stack's --datadir= option in stack.yaml causes stack to write cabal's data-files to datadir during stack build. This breaks package manager GNU DESTDIR capability, as discussed in #848. Here is an example automated build that illustrates the problem.

In contrast, specifying datadir in the cabal file Paths_packagename.hs, causes stack to write cabal's data-files to the default .stack-work location during the build, and produce a binary with a correctly hardcoded path in PREFIX. This approach was described years ago by hlint's author @ndmitchell.

Here is the `stack.yaml' configuration that produces the issue:

configure-options:
  packagename:
  - --datadir=/path/to/my/datadir

Here is an automated stack build that solves the issue with related files:

Also noted for posterity: setting the environment variable packagename_datadir at runtime overrides the binary's hardcoded packagename_datadir path.

I believe that stack's behavior should be the same as setting datadir in Paths_packagename.hs, which would fix a longstanding problem of hardcoded paths of the build directory in stack binaries when cabal data-files exist in packagename.cabal.

This is related to: