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

git is required to build i3 #2833

Open
acrisci opened this Issue Jul 11, 2017 · 14 comments

Comments

Projects
None yet
6 participants
@acrisci
Member

acrisci commented Jul 11, 2017

I just ran into this issue building in a vm without git.

The build fails with

In file included from ../../i3/src/ipc.c:12:0:
../../i3/src/ipc.c: In function ‘handle_get_version’:
../../i3/include/yajl_utils.h:19:50: error: expected expression before ‘)’ token
 #define y(x, ...) yajl_gen_##x(gen, ##__VA_ARGS__)
                                                  ^
../../i3/src/ipc.c:908:5: note: in expansion of macro ‘y’
     y(integer, MAJOR_VERSION);
     ^
../../i3/include/yajl_utils.h:19:50: error: expected expression before ‘)’ token
 #define y(x, ...) yajl_gen_##x(gen, ##__VA_ARGS__)
                                                  ^
../../i3/src/ipc.c:911:5: note: in expansion of macro ‘y’
     y(integer, MINOR_VERSION);

I believe the problem is that those don't get defined properly. After installing git, it worked.

We should add a check in configure.ac to make sure git is installed.

@i3bot i3bot added the missing-log label Jul 11, 2017

@i3bot

This comment has been minimized.

Show comment
Hide comment
@i3bot

i3bot Jul 11, 2017

I don’t see a link to logs.i3wm.org. Did you follow http://i3wm.org/docs/debugging.html? (In case you actually provided a link to a logfile, please ignore me.)

i3bot commented Jul 11, 2017

I don’t see a link to logs.i3wm.org. Did you follow http://i3wm.org/docs/debugging.html? (In case you actually provided a link to a logfile, please ignore me.)

@i3bot

This comment has been minimized.

Show comment
Hide comment
@i3bot

i3bot Jul 11, 2017

I don’t see a version number. Could you please copy & paste the output of i3 --version into this issue?

i3bot commented Jul 11, 2017

I don’t see a version number. Could you please copy & paste the output of i3 --version into this issue?

@Airblader

This comment has been minimized.

Show comment
Hide comment
@Airblader

Airblader Jul 11, 2017

Member

Actually we support out of tree builds. I also don't quite know why this would require git, but we should find out and fix it.

Member

Airblader commented Jul 11, 2017

Actually we support out of tree builds. I also don't quite know why this would require git, but we should find out and fix it.

@giuscri

This comment has been minimized.

Show comment
Hide comment
@giuscri

giuscri Jul 11, 2017

Can't reproduce this on Linux ubuntu-artful 4.10.0-26-generic #30-Ubuntu SMP Tue Jun 27 09:30:12 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux with git removed.

ubuntu@ubuntu-artful:~/i3-fix-2832/build$ apt list --installed 2>&1|grep git
findutils/artful,now 4.6.0+git+20170606-3 amd64 [installed]
git-man/artful,now 1:2.11.0-4 all [installed]
libgolang-github-gorilla-context1/artful,now 1.1-1ubuntu9 amd64 [installed]
libgolang-github-gorilla-mux1/artful,now 1.1-2ubuntu8 amd64 [installed]
libgolang-github-gorilla-websocket1/artful,now 1.1.0-1ubuntu1 amd64 [installed]
libgolang-github-gosexy-gettext1/artful,now 0~git20130221-0ubuntu13 amd64 [installed]
libgolang-github-mattn-go-colorable1/artful,now 0.0.6-1ubuntu6 amd64 [installed]
libgolang-github-mattn-go-sqlite3-1/artful,now 1.1.0~dfsg1-3ubuntu1 amd64 [installed]
libgolang-github-olekukonko-tablewriter1/artful,now 0.0~git20151029.0.a5eefc2-1ubuntu7 amd64 [installed]
libgolang-github-pborman-uuid1/artful,now 0.0+git20150824.0.cccd189-1ubuntu8 amd64 [installed]
libgolang-gocapability1/artful,now 0.0~git20160928.0.e7cb7fa-1ubuntu1 amd64 [installed]
libgolang-golang-x-crypto1/artful,now 1:0.0~git20170407.0.55a552f-1ubuntu1 amd64 [installed]
libgolang-golang-x-net1/artful,now 1:0.0+git20170114.0.f249948+dfsg-0ubuntu2 amd64 [installed]
libgolang-golang-x-text1/artful,now 0.0~git20161013.0.c745997-2ubuntu2 amd64 [installed]
libgolang-gopkg-flosch-pongo2.v3-1/artful,now 3.0+git20141028.0.5e81b81-0ubuntu8 amd64 [installed]
libgolang-gopkg-inconshreveable-log15.v2-1/artful,now 2.11+git20150921.0.b105bd3-0ubuntu11 amd64 [installed]
libgolang-gopkg-lxc-go-lxc.v2-1/artful,now 0.0~git20161126.1.82a07a6-0ubuntu4 amd64 [installed]
libgolang-gopkg-tomb.v2-1/artful,now 0.0~git20161208.0.d5d1b58-1ubuntu1 amd64 [installed]
libgolang-gopkg-yaml.v2-1/artful,now 0.0+git20170125.0.4c78c97-0ubuntu2 amd64 [installed]
libgolang-goprotobuf1/artful,now 0.0~git20161116.0.224aaba-3ubuntu2 amd64 [installed]
librtmp1/artful,now 2.4+20151223.gitfa8646d.1-1 amd64 [installed]
net-tools/artful,now 1.60+git20161116.90da8a0-1ubuntu1 amd64 [installed]
open-iscsi/artful,now 2.0.873+git0.3b4b4500-14ubuntu17 amd64 [installed]
sysvinit-utils/artful,now 2.88dsf-59.8git1 amd64 [installed]

giuscri commented Jul 11, 2017

Can't reproduce this on Linux ubuntu-artful 4.10.0-26-generic #30-Ubuntu SMP Tue Jun 27 09:30:12 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux with git removed.

ubuntu@ubuntu-artful:~/i3-fix-2832/build$ apt list --installed 2>&1|grep git
findutils/artful,now 4.6.0+git+20170606-3 amd64 [installed]
git-man/artful,now 1:2.11.0-4 all [installed]
libgolang-github-gorilla-context1/artful,now 1.1-1ubuntu9 amd64 [installed]
libgolang-github-gorilla-mux1/artful,now 1.1-2ubuntu8 amd64 [installed]
libgolang-github-gorilla-websocket1/artful,now 1.1.0-1ubuntu1 amd64 [installed]
libgolang-github-gosexy-gettext1/artful,now 0~git20130221-0ubuntu13 amd64 [installed]
libgolang-github-mattn-go-colorable1/artful,now 0.0.6-1ubuntu6 amd64 [installed]
libgolang-github-mattn-go-sqlite3-1/artful,now 1.1.0~dfsg1-3ubuntu1 amd64 [installed]
libgolang-github-olekukonko-tablewriter1/artful,now 0.0~git20151029.0.a5eefc2-1ubuntu7 amd64 [installed]
libgolang-github-pborman-uuid1/artful,now 0.0+git20150824.0.cccd189-1ubuntu8 amd64 [installed]
libgolang-gocapability1/artful,now 0.0~git20160928.0.e7cb7fa-1ubuntu1 amd64 [installed]
libgolang-golang-x-crypto1/artful,now 1:0.0~git20170407.0.55a552f-1ubuntu1 amd64 [installed]
libgolang-golang-x-net1/artful,now 1:0.0+git20170114.0.f249948+dfsg-0ubuntu2 amd64 [installed]
libgolang-golang-x-text1/artful,now 0.0~git20161013.0.c745997-2ubuntu2 amd64 [installed]
libgolang-gopkg-flosch-pongo2.v3-1/artful,now 3.0+git20141028.0.5e81b81-0ubuntu8 amd64 [installed]
libgolang-gopkg-inconshreveable-log15.v2-1/artful,now 2.11+git20150921.0.b105bd3-0ubuntu11 amd64 [installed]
libgolang-gopkg-lxc-go-lxc.v2-1/artful,now 0.0~git20161126.1.82a07a6-0ubuntu4 amd64 [installed]
libgolang-gopkg-tomb.v2-1/artful,now 0.0~git20161208.0.d5d1b58-1ubuntu1 amd64 [installed]
libgolang-gopkg-yaml.v2-1/artful,now 0.0+git20170125.0.4c78c97-0ubuntu2 amd64 [installed]
libgolang-goprotobuf1/artful,now 0.0~git20161116.0.224aaba-3ubuntu2 amd64 [installed]
librtmp1/artful,now 2.4+20151223.gitfa8646d.1-1 amd64 [installed]
net-tools/artful,now 1.60+git20161116.90da8a0-1ubuntu1 amd64 [installed]
open-iscsi/artful,now 2.0.873+git0.3b4b4500-14ubuntu17 amd64 [installed]
sysvinit-utils/artful,now 2.88dsf-59.8git1 amd64 [installed]
@acrisci

This comment has been minimized.

Show comment
Hide comment
@acrisci

acrisci Jul 12, 2017

Member

Thanks for triaging my bug, @giuscri .

Note that only the configure step is affected by this. If the project is configured with git installed on the build system, then making the project will proceed normally whether or not git is installed.

The reliance on the git binary can be seen in configure.ac:

AS_IF([test -d ${srcdir}/.git],
      [
        VERSION="$(git -C ${srcdir} describe --tags --abbrev=0)"
        I3_VERSION="$(git -C ${srcdir} describe --tags --always) ($(git -C ${srcdir} log --pretty=format:%cd --date=short -n1), branch \\\"$(git -C ${srcdir} describe --tags --always --all | sed s:heads/::)\\\")"
        # Mirrors what libi3/is_debug_build.c does:
        is_release=$(test $(echo "${I3_VERSION}" | cut -d '(' -f 1 | wc -m) -lt 10 && echo yes || echo no)
      ],
      [
        VERSION="$(cut -d '-' -f 1 ${srcdir}/I3_VERSION | cut -d ' ' -f 1)"
        I3_VERSION="$(sed -e 's/@<:@\"?\\@:>@/\\&/g' ${srcdir}/I3_VERSION)"
        is_release="$(grep -q non-git ${srcdir}/I3_VERSION && echo no || echo yes)"
      ])
AC_SUBST([I3_VERSION], [$I3_VERSION])
MAJOR_VERSION="$(echo ${VERSION} | cut -d '.' -f 1)"
MINOR_VERSION="$(echo ${VERSION} | cut -d '.' -f 2)"
PATCH_VERSION="$(echo ${VERSION} | cut -d '.' -f 3)"
AS_IF([test "x${PATCH_VERSION}" = x], [PATCH_VERSION=0])
AC_DEFINE_UNQUOTED([I3_VERSION], ["${I3_VERSION}"], [i3 version])
AC_DEFINE_UNQUOTED([MAJOR_VERSION], [${MAJOR_VERSION}], [i3 major version])
AC_DEFINE_UNQUOTED([MINOR_VERSION], [${MINOR_VERSION}], [i3 minor version])
AC_DEFINE_UNQUOTED([PATCH_VERSION], [${PATCH_VERSION}], [i3 patch version])

Now ./configure prints to stderr

.././configure: line 3390: git: command not found
.././configure: line 3391: git: command not found
.././configure: line 3391: git: command not found
.././configure: line 3391: git: command not found

The command to set I3_VERSION has failed. When I try to echo the MINOR_VERSION variable after it is set, I see that it is blank. Thus the macro never gets expanded in the source file and the error follows.

Member

acrisci commented Jul 12, 2017

Thanks for triaging my bug, @giuscri .

Note that only the configure step is affected by this. If the project is configured with git installed on the build system, then making the project will proceed normally whether or not git is installed.

The reliance on the git binary can be seen in configure.ac:

AS_IF([test -d ${srcdir}/.git],
      [
        VERSION="$(git -C ${srcdir} describe --tags --abbrev=0)"
        I3_VERSION="$(git -C ${srcdir} describe --tags --always) ($(git -C ${srcdir} log --pretty=format:%cd --date=short -n1), branch \\\"$(git -C ${srcdir} describe --tags --always --all | sed s:heads/::)\\\")"
        # Mirrors what libi3/is_debug_build.c does:
        is_release=$(test $(echo "${I3_VERSION}" | cut -d '(' -f 1 | wc -m) -lt 10 && echo yes || echo no)
      ],
      [
        VERSION="$(cut -d '-' -f 1 ${srcdir}/I3_VERSION | cut -d ' ' -f 1)"
        I3_VERSION="$(sed -e 's/@<:@\"?\\@:>@/\\&/g' ${srcdir}/I3_VERSION)"
        is_release="$(grep -q non-git ${srcdir}/I3_VERSION && echo no || echo yes)"
      ])
AC_SUBST([I3_VERSION], [$I3_VERSION])
MAJOR_VERSION="$(echo ${VERSION} | cut -d '.' -f 1)"
MINOR_VERSION="$(echo ${VERSION} | cut -d '.' -f 2)"
PATCH_VERSION="$(echo ${VERSION} | cut -d '.' -f 3)"
AS_IF([test "x${PATCH_VERSION}" = x], [PATCH_VERSION=0])
AC_DEFINE_UNQUOTED([I3_VERSION], ["${I3_VERSION}"], [i3 version])
AC_DEFINE_UNQUOTED([MAJOR_VERSION], [${MAJOR_VERSION}], [i3 major version])
AC_DEFINE_UNQUOTED([MINOR_VERSION], [${MINOR_VERSION}], [i3 minor version])
AC_DEFINE_UNQUOTED([PATCH_VERSION], [${PATCH_VERSION}], [i3 patch version])

Now ./configure prints to stderr

.././configure: line 3390: git: command not found
.././configure: line 3391: git: command not found
.././configure: line 3391: git: command not found
.././configure: line 3391: git: command not found

The command to set I3_VERSION has failed. When I try to echo the MINOR_VERSION variable after it is set, I see that it is blank. Thus the macro never gets expanded in the source file and the error follows.

acrisci added a commit to acrisci/i3 that referenced this issue Jul 12, 2017

Improve git detection in configure.ac
During the configure step, if the git binary is not on the system, the
*_VERSION variables will not be set properly which will cause a build
error.

Fix this bug by falling back to the non-git version detection scheme
when git is not installed.

fixes #2833
@Airblader

This comment has been minimized.

Show comment
Hide comment
@Airblader

Airblader Jul 13, 2017

Member

Out of curiosity, how did you get the sources with git subfolder without having git installed? The release tarballs don't include that folder.

Member

Airblader commented Jul 13, 2017

Out of curiosity, how did you get the sources with git subfolder without having git installed? The release tarballs don't include that folder.

@acrisci

This comment has been minimized.

Show comment
Hide comment
@acrisci

acrisci Jul 13, 2017

Member

I was trying to test that the installation paths still worked on another issue so I spun up a VM for that testing and did scp -r on my project directory because it was the easiest thing to do at the time.

Member

acrisci commented Jul 13, 2017

I was trying to test that the installation paths still worked on another issue so I spun up a VM for that testing and did scp -r on my project directory because it was the easiest thing to do at the time.

@giuscri

This comment has been minimized.

Show comment
Hide comment
@giuscri

giuscri Jul 17, 2017

@acrisci,

The reliance on the git binary can be seen in configure.ac

To my understanding that's not true. In fact, from the autoconf documentation:

— Macro: AS_IF (test1, [run-if-true1], ..., [run-if-false])
Run shell code test1. If test1 exits with a zero status then run shell code run-if-true1, else examine further tests. If no test exits with a zero status, run shell code run-if-false, with simplifications if either run-if-true1 or run-if-false is empty.

In the snippet from configure.ac you posted, /usr/bin/git is not used if there's no .git directory - which is the case for release tarballs.

ubuntu@ubuntu-artful:~/i3-next$ which git
ubuntu@ubuntu-artful:~/i3-next$ autoreconf --version|head -n1
autoreconf (GNU Autoconf) 2.69
ubuntu@ubuntu-artful:~/i3-next$ autoreconf -fi
Makefile.am:208: warning: '%'-style pattern rules are a GNU make extension
ubuntu@ubuntu-artful:~/i3-next$ cd build/
ubuntu@ubuntu-artful:~/i3-next/build$ ../configure 
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
...
--------------------------------------------------------------------------------
build configured:

  i3 version:             4.13-non-git
  is release version:     no

  build manpages:         no
  build docs:             no
  enable debug flags:     yes
  code coverage:          no
  enabled sanitizers:     address 

To compile, run:

  cd /home/ubuntu/i3-next/build && make -j8
--------------------------------------------------------------------------------

giuscri commented Jul 17, 2017

@acrisci,

The reliance on the git binary can be seen in configure.ac

To my understanding that's not true. In fact, from the autoconf documentation:

— Macro: AS_IF (test1, [run-if-true1], ..., [run-if-false])
Run shell code test1. If test1 exits with a zero status then run shell code run-if-true1, else examine further tests. If no test exits with a zero status, run shell code run-if-false, with simplifications if either run-if-true1 or run-if-false is empty.

In the snippet from configure.ac you posted, /usr/bin/git is not used if there's no .git directory - which is the case for release tarballs.

ubuntu@ubuntu-artful:~/i3-next$ which git
ubuntu@ubuntu-artful:~/i3-next$ autoreconf --version|head -n1
autoreconf (GNU Autoconf) 2.69
ubuntu@ubuntu-artful:~/i3-next$ autoreconf -fi
Makefile.am:208: warning: '%'-style pattern rules are a GNU make extension
ubuntu@ubuntu-artful:~/i3-next$ cd build/
ubuntu@ubuntu-artful:~/i3-next/build$ ../configure 
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
...
--------------------------------------------------------------------------------
build configured:

  i3 version:             4.13-non-git
  is release version:     no

  build manpages:         no
  build docs:             no
  enable debug flags:     yes
  code coverage:          no
  enabled sanitizers:     address 

To compile, run:

  cd /home/ubuntu/i3-next/build && make -j8
--------------------------------------------------------------------------------
@gfazio

This comment has been minimized.

Show comment
Hide comment
@gfazio

gfazio Feb 15, 2018

I found the link to this because I was having a similar problem with compiling.
acrisici's comments above with regards to configure.ac helped me to solve it.

In configure.ac where (as pointed out by acrisci) it says:

AS_IF([test -d ${srcdir}/.git], [ VERSION="$(git -C ${srcdir} describe --tags --abbrev=0)" I3_VERSION="$(git -C ${srcdir} describe --tags --always) ($(git -C ${srcdir} log --pretty=format:%cd --date=short -n1), branch \\\"$(git -C ${srcdir} describe --tags --always --all | sed s:heads/::)\\\")" # Mirrors what libi3/is_debug_build.c does: is_release=$(test $(echo "${I3_VERSION}" | cut -d '(' -f 1 | wc -m) -lt 10 && echo yes || echo no) ],

The VERSION number will come out empty, because this line

VERSION="$(git -C ${srcdir} describe --tags --abbrev=0)"

should be

VERSION="$(git -c ${srcdir} describe --tags --abbrev=0)"

At least that's the case with my version of git (1.8.3.1)

Once I'd made that change then the configuration/build completed successfully

gfazio commented Feb 15, 2018

I found the link to this because I was having a similar problem with compiling.
acrisici's comments above with regards to configure.ac helped me to solve it.

In configure.ac where (as pointed out by acrisci) it says:

AS_IF([test -d ${srcdir}/.git], [ VERSION="$(git -C ${srcdir} describe --tags --abbrev=0)" I3_VERSION="$(git -C ${srcdir} describe --tags --always) ($(git -C ${srcdir} log --pretty=format:%cd --date=short -n1), branch \\\"$(git -C ${srcdir} describe --tags --always --all | sed s:heads/::)\\\")" # Mirrors what libi3/is_debug_build.c does: is_release=$(test $(echo "${I3_VERSION}" | cut -d '(' -f 1 | wc -m) -lt 10 && echo yes || echo no) ],

The VERSION number will come out empty, because this line

VERSION="$(git -C ${srcdir} describe --tags --abbrev=0)"

should be

VERSION="$(git -c ${srcdir} describe --tags --abbrev=0)"

At least that's the case with my version of git (1.8.3.1)

Once I'd made that change then the configuration/build completed successfully

@giuscri

This comment has been minimized.

Show comment
Hide comment
@giuscri

giuscri Feb 15, 2018

@gfazio -C has been introduced by git/git@44e1e4d, after 1.8.3.1 release. I've tried to address this problem in #3141, but this is definitely another issue.

giuscri commented Feb 15, 2018

@gfazio -C has been introduced by git/git@44e1e4d, after 1.8.3.1 release. I've tried to address this problem in #3141, but this is definitely another issue.

@giuscri

This comment has been minimized.

Show comment
Hide comment
@giuscri

giuscri Feb 15, 2018

@gfazio why do you have such an old version of git? Post your uname -a please

giuscri commented Feb 15, 2018

@gfazio why do you have such an old version of git? Post your uname -a please

@gfazio

This comment has been minimized.

Show comment
Hide comment
@gfazio

gfazio Feb 27, 2018

Apologies for the late reply - I hadn't noticed that my comment had generated further questions. The reason I have such an old version of git is that my department runs scientific linux version 7.4.
uname -a gives the following output:

Linux 3.10.0-693.17.1.el7.x86_64 #1 SMP x86_64 x86_64 x86_64 GNU/Linux

cheers

Vito

gfazio commented Feb 27, 2018

Apologies for the late reply - I hadn't noticed that my comment had generated further questions. The reason I have such an old version of git is that my department runs scientific linux version 7.4.
uname -a gives the following output:

Linux 3.10.0-693.17.1.el7.x86_64 #1 SMP x86_64 x86_64 x86_64 GNU/Linux

cheers

Vito

@giuscri

This comment has been minimized.

Show comment
Hide comment
@giuscri

giuscri Feb 28, 2018

is git the only dependency you had problem with?

giuscri commented Feb 28, 2018

is git the only dependency you had problem with?

@vgg

This comment has been minimized.

Show comment
Hide comment
@vgg

vgg commented Apr 13, 2018

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment