Skip to content

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

Open

Description

@essandess

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:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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