Skip to content

data-dir mismatch when installing component #6235

Open

Description

@aherrmann

Describe the bug
When configuring, building, and installing a package component, instead of the whole package, Cabal will generate a datadir value in the Paths_* module that does not match the actual installation datadir. Potentially leading to file not found errors at runtime of the install package component.

To Reproduce

Fetch and unpack the alex source distribution

$ curl -L http://hackage.haskell.org/package/alex-3.2.4/alex-3.2.4.tar.gz | tar xz
$ cd alex-3.2.4

Configure and install the exe:alex component

$ mkdir install_dir
$ runghc Setup.hs configure exe:alex --user --prefix=$PWD/install_dir --datadir=$PWD/install_dir/alex_data
$ runghc Setup.hs build
$ runghc Setup.hs install

Observe a mismatch in the actual datadir and the datadir expected by Paths_alex:

$ grep 'datadir\s*=' dist/build/alex/autogen/Paths_alex.hs
datadir    = "/tmp/alex-3.2.4/install_dir/alex_data/x86_64-linux-ghc-8.6.5/alex-3.2.4-BnUEMKTG1CcF5xN1sTDkoW-alex"
$ ls install_dir/alex_data/x86_64-linux-ghc-8.6.5/
alex-3.2.4

Expected behavior
The datadir value in Paths_alex.hs should match the actual installation directory.

System informataion

  • Operating system: 5.1.4-1-default x86_64 GNU/Linux
  • $ runghc Setup.hs --version
    Cabal library version 2.4.0.1
    

Additional context
This issue can be worked around by setting the --datasubdir= flag, which overrides the default subdirectory under --datadir and does not depend on the component.

Activity

  1. lemmih commented on Aug 25, 2020

    @lemmih
    Contributor

    This is a huge problem for reanimate as well. The bug can be seen by creating a package with a data file and exposing the generated Paths module. Running cabal v2-exec -- ghc -e Paths_{package}.getDataDir will return the wrong path.

  2. added this to the Considered for 3.12 milestone on Jun 8, 2023
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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions