haskell / haskell/cabal

data-dir mismatch when installing component

Open
#6,235 1 comment 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**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.

Contributor guide

Open the contributing guide

Research direction

Reproduce the mismatch with the provided Setup.hs configure, build, and install commands, then compare the generated dist/build/alex/autogen/Paths_alex.hs datadir with the installed directory under install_dir/alex_data. Trace how the component and --datasubdir settings determine these paths; done means the generated datadir matches the actual installation directory for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.