haskell / haskell/cabal

The exe created by `cabal build` gets outdated `data-files`

Open
#11,124 1 comment 1 reaction 0 assignees View on GitHub
cabal-install: cmd/build data-files type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

For `cabal run`, the `datadir` points to the source tree, so one gets always the latest version of the app's `data-files`.
The executable produced by `cabal build` gets a `datadir` pointing to `~/.cabal/share/...` but _this may contain outdated versions of the `data-files`_.
It seems like `cabal build` does not copy the latest versions of the `data-files` there.

Experiment in the Agda code base:
```
$ cabal run agda -- --print-agda-data-dir 2>/dev/null
Resolving dependencies...
/Users/abela/agda/src/data

$ l $(cabal run agda -- --print-agda-data-dir 2>/dev/null | tail -1)/emacs-mode/agda2-mode.el
-rw-r--r-- 1 abela staff 84844 Aug 4 11:18 /Users/abela/agda/src/data/emacs-mode/agda2-mode.el
````
This data-file is up-to-date (naturally, as it is in the source tree).
```
$ cabal build agda 2>/dev/null
Resolving dependencies...
Up to date

$ $(cabal list-bin agda 2>/dev/null) --print-agda-data-dir
/Users/abela/.cabal/share/aarch64-osx-ghc-9.12.2-ea3d/Agda-2.9.0

$ l $($(cabal list-bin agda 2>/dev/null) --print-agda-data-dir)/emacs-mode/agda2-mode.el
-rw-r--r-- 1 abela staff 84757 Jul 7 19:31 /Users/abela/.cabal/share/aarch64-osx-ghc-9.12.2-ea3d/Agda-2.9.0/emacs-mode/agda2-mode.el
```
The data-file that the binary gets served is outdated (dated July 7th).

Tried both with cabal 3.16.0.0 and 3.14.2.0.
Update: also tried 3.12.1.0 and 3.10.3.0.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Agda experiment with `cabal run`, `cabal build`, and `cabal list-bin`, comparing the source-tree and `~/.cabal/share/...` data directories. Investigate how `cabal build` handles declared `data-files`; done means the built executable receives the latest data-file versions rather than stale copies.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.