Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
newhoggy opened this issue Apr 12, 2021 · 5 comments
Open
Labels
cabal-install: cmd/install can-workaround There is a (maybe partial) workaround for the issue or missing feature type: user-question

Comments

@newhoggy
Copy link

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

@newhoggy
Copy link
Author

See acfoltzer/gitrev#23

@newhoggy
Copy link
Author

The problem occurs here: IntersectMBO/cardano-node#1127

@typedrat
Copy link
Collaborator

This shouldn't work!

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

extra-source-files: ../.git/HEAD
                  , ../.git/refs/heads/master

to your cabal file.

@gbaz
Copy link
Collaborator

gbaz commented Sep 2, 2021

Does the above comment suffice to close this?

@DavSanchez
Copy link

DavSanchez commented 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.

@jneira jneira added the can-workaround There is a (maybe partial) workaround for the issue or missing feature label Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cabal-install: cmd/install can-workaround There is a (maybe partial) workaround for the issue or missing feature type: user-question
Projects
None yet
Development

No branches or pull requests

6 participants