You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Need a way to embed git revision into executable when running cabal install #7355
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
As it stands, you have an undeclared data dependency on the .git folder, and cabal install is keeping you honest by only giving you access during installation build to the files that you have declared yourself to depend on, because it needs to know the set of dependencies that you have in order to be able to compute the hash of the current input state and know if it needs to reinstall the program!
This is made somewhat inconvenient because Cabal fails to support globbing files without extensions or otherwise including the full contents of a directory in extra-source-files, but is easy enough to fix for the case of the master branch by adding
The solution proposed by @typedrat is unfortunately not working for me, although I think it makes sense that it should. I'll try to troubleshoot what could be happening under the hood but not sure if I'll reach something.
Activity
newhoggy commentedon Apr 12, 2021
See acfoltzer/gitrev#23
newhoggy commentedon Apr 12, 2021
The problem occurs here: IntersectMBO/cardano-node#1127
typedrat commentedon Apr 15, 2021
This shouldn't work!
As it stands, you have an undeclared data dependency on the
.gitfolder, andcabal installis keeping you honest by only giving you access during installation build to the files that you have declared yourself to depend on, because it needs to know the set of dependencies that you have in order to be able to compute the hash of the current input state and know if it needs to reinstall the program!This is made somewhat inconvenient because Cabal fails to support globbing files without extensions or otherwise including the full contents of a directory in
extra-source-files, but is easy enough to fix for the case of themasterbranch by addingextra-source-files: ../.git/HEAD , ../.git/refs/heads/masterto your cabal file.
gbaz commentedon Sep 2, 2021
Does the above comment suffice to close this?
DavSanchez commentedon Oct 19, 2021
The solution proposed by @typedrat is unfortunately not working for me, although I think it makes sense that it should. I'll try to troubleshoot what could be happening under the hood but not sure if I'll reach something.