IntersectMBO / cardano-node

The core component that is used to participate in a Cardano decentralised blockchain.
https://cardano.org
Apache License 2.0
3.06k stars 718 forks source link

[BUG] - git rev 00000000000000000000 after building with cabal install #1127

Closed CarlosLopezDeLara closed 2 years ago

CarlosLopezDeLara commented 4 years ago

Summary

Getting git rev 00000000000000000000 after building with cabal install.

Steps to reproduce Steps to reproduce the behavior:

After building with 'cabal install' :

~/cardano-node$ cardano-node --version 
cardano-cli 1.12.0 - linux-x86_64 - ghc-8.6
git rev 0000000000000000000000000000000000000000

Expected behavior Show the latest commit? Hide the git rev to avoid confusion?

System info (please complete the following information):

cardanobay commented 4 years ago

Can confirm this small bug on Debian 10 and Centos 8. Bug happen only with "cabal install...", using "cabal build..." result in a binary that shows the correct git rev. edit : building on git checkout tags/1.13.0

erikd commented 4 years ago

If what you say is true, this is actually a bug in the Haskell tooling. If that is the case, I am pretty sure the tooling bugs can be worked around using cabal build ... && cabal install ...

cardanobay commented 4 years ago

For information for thoses who may once have this bug. I just finished compiling the binary with theses commands :

$ cabal update
$ git fetch --all --tags
$ git tag
$ git checkout tags/1.13.0
$ cabal build cardano-node && cabal install cardano-node

Results :

Binary resulting of the cabal build command (97 MB)

cardano@sp01:cardano-node$ /home/cardano/cardano-node/dist-newstyle/build/x86_64-linux/ghc-8.6.5/cardano-node-1.13.0/x/cardano-node/build/cardano-node/cardano-node version
cardano-cli 1.13.0 - linux-x86_64 - ghc-8.6
git rev 9925ef37dccbe7f423f3ceb81a5e1da3d924393b

Binary resulting of the cabal install command (104 MB)

cardano@sp01:cardano-node$ /home/cardano/.cabal/store/ghc-8.6.5/cardano-node-1.13.0-5913b03154e8c88ac85fd6e313c9dd01a6e8ed032ac968baa4bb9b05302bb916/bin/cardano-node version
cardano-cli 1.13.0 - linux-x86_64 - ghc-8.6
git rev 0000000000000000000000000000000000000000

I will personally just use the "build" command instead of the "install", because the resulting binary is smaller, and don't include this small bug. I don't understand why the binaries are different, but the node is running without any bugs.

mark-stopka commented 4 years ago

Linking for reference https://github.com/input-output-hk/cardano-node/issues/1342

newhoggy commented 3 years ago

A bit of background.

cabal sdist creates collects source files required for compilation into a tar.gz which is the package that gets uploaded to hackage.

cabal install is meant to behave as you've run cabal sdist then extract the tar.gz file elsewhere and run cabal build from there.

Unfortunately, git information does not make it into the tar.gz file so the library we use gitrev is unable to find the git revision.

For example when I run cabal install on my make, the sources get copied to something like /private/var/folders/zh/ln41q4zs52x2fd61rxccmq640000gn/T/cabal-install.-79645/dist-newstyle/tmp/src-79645/cardano-config-0.1.0.0.

This problem is not unique to cardano-node: https://www.reddit.com/r/haskell/comments/erhwe8/what_is_the_best_way_to_inject_information_into_a/ff5p7r6/?utm_source=share&utm_medium=web2x

I don't know of any way to tell cabal install to include the git revision.

newhoggy commented 3 years ago

I reported this https://github.com/haskell/cabal/issues/7355

mark-stopka commented 3 years ago

A bit of background.

cabal sdist creates collects source files required for compilation into a tar.gz which is the package that gets uploaded to hackage.

cabal install is meant to behave as you've run cabal sdist then extract the tar.gz file elsewhere and run cabal build from there.

Unfortunately, git information does not make it into the tar.gz file so the library we use gitrev is unable to find the git revision.

For example when I run cabal install on my make, the sources get copied to something like /private/var/folders/zh/ln41q4zs52x2fd61rxccmq640000gn/T/cabal-install.-79645/dist-newstyle/tmp/src-79645/cardano-config-0.1.0.0.

This problem is not unique to cardano-node: https://www.reddit.com/r/haskell/comments/erhwe8/what_is_the_best_way_to_inject_information_into_a/ff5p7r6/?utm_source=share&utm_medium=web2x

I don't know of any way to tell cabal install to include the git revision.

Thanks for the in-depth analysis, I hope we can work with upstream on solving it =)