haskell / haskell/cabal

Need a way to embed git revision into executable when running cabal install

Open
#7,355 5 comments 0 reactions 0 assignees View on GitHub
cabal-install: cmd/install can-workaround type: user-question
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
When `cabal install` is run, instead of building in place, it copies to source to some other location and builds from that location. For example on my Mac it builds from somewhere like this: `/private/var/folders/zh/ln41q4zs52x2fd61rxccmq640000gn/T/cabal-install.-79645/dist-newstyle/tmp/src-79645/cardano-config-0.1.0.0`

As a result, whilst libraries like `gitrev` allow you to embed the git revision when you run `cabal build`, this does not work with `cabal install`.

There needs to be some mechanism to allow the build to capture the git revision when `cabal install` is used.

**To Reproduce**
On any project that uses `gitrev` or some similar git revision embedding library, run `cabal v2-install`.

Then observe that the the git revision is not embedded.

**Expected behavior**
The git revision should be embedded, or if not, some other mechanism needs to be provided to make this possible

**System information**
`cabal-3.4`

**Additional context**
N/A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.