r-lib / gert

Simple git client for R
https://docs.ropensci.org/gert/
Other
146 stars 31 forks source link

compilation failed with libgit2 1.8.0 #213

Closed hengtseChou closed 3 months ago

hengtseChou commented 4 months ago

I am running R on arch-based linux and cannot install the gert package. The error code is listed below. I am not sure is the r version or the compiler causing this issue, since I installed them successfully before. Thank you.

install.packages("gert")
* installing *source* package ‘gert’ ...
** package ‘gert’ successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=
Using PKG_LIBS=-lgit2
Configuration OK!
** libs
using C compiler: ‘gcc (GCC) 14.1.1 20240507’
rm -f gert.so branch.o clone.o commit.o config.o conflicts.o files.o ignore.o init.o merge.o rebase.o stash.o submodules.o tag.o utils.o version.o
gcc -I"/usr/include/R/" -DNDEBUG -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include   -fvisibility=hidden -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/r/src=/usr/src/debug/r -flto=auto -ffat-lto-objects  -c branch.c -o branch.o
gcc -I"/usr/include/R/" -DNDEBUG -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include   -fvisibility=hidden -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/r/src=/usr/src/debug/r -flto=auto -ffat-lto-objects  -c clone.c -o clone.o
gcc -I"/usr/include/R/" -DNDEBUG -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include   -fvisibility=hidden -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/r/src=/usr/src/debug/r -flto=auto -ffat-lto-objects  -c commit.c -o commit.o
commit.c: In function ‘R_git_commit_create’:
commit.c:162:60: error: passing argument 10 of ‘git_commit_create’ from incompatible pointer type [-Wincompatible-pointer-types]
  162 |                             msg.ptr, tree, number_parents, parents), "git_commit_create");
      |                                                            ^~~~~~~
      |                                                            |
      |                                                            const git_commit **
In file included from /usr/include/git2/repository.h:14,
                 from /usr/include/git2/annotated_commit.h:11,
                 from /usr/include/git2.h:11,
                 from utils.h:1,
                 from commit.c:2:
/usr/include/git2/commit.h:369:28: note: expected ‘git_commit * const*’ but argument is of type ‘const git_commit **’
  369 |         git_commit * const parents[]);
      |         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~
make: *** [/usr/lib64/R/etc/Makeconf:195: commit.o] Error 1
ERROR: compilation failed for package ‘gert’
* removing ‘/home/hank/R/x86_64-pc-linux-gnu-library/4.4/gert’
Warning in install.packages :
  installation of package ‘gert’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpLu9S2U/downloaded_packages’
hengtseChou commented 4 months ago

I did make sure that libgit2 is installed.

jeroen commented 4 months ago

Thanks for the report. Which version of libgit2 is this?

I am guessing that gcc 14 (which was released a few days ago and already seems to be in archlinux) is using some stricter type checking, revealing a bug. I'll look into it asap.

hengtseChou commented 4 months ago

Thanks for the quick response. The version of libgit2 is 1:1.8.0-2.

jeroen commented 3 months ago

It looks like this is actually a break in libgit2 1.8.0: https://github.com/libgit2/libgit2/issues/6793

This might explain why most distros (debian/homebrew/fedora) are staying with libgit2 1.7.2 for now. There are some discussions here: https://github.com/Homebrew/homebrew-core/pull/166767#issuecomment-2049709027

As a temporary workaround you can try to uninstall the libgit2 from your machine, in which case gert will try to download a compatible libgit2 version at install time.

hengtseChou commented 3 months ago

I downgraded libgit2 to 1.7.2 and this time gert compiled with no issue. Thank you.

ns-rse commented 3 months ago

I've encountered this issue too (also under Arch Linux) and downgrading to libgit-1.7.2 worked for me until recently when I needed to upgrade it since libgit is a dependency of other programmes on my system. I've encountered the same under Gentoo too (no surprise that this crops up on rolling release distros!).

It looks like a workaround is coming soon with #216 and release 2.0.2 which is great.

Thanks for all the hard work on this and other libraries, very much appreciated.

chenrui333 commented 1 month ago

fyi, homebrew has shipped libgit2 1.8.0

jeroen commented 1 month ago

Thanks. I have submitted an update for gert to CRAN, so it should be available soon.

jeroen commented 1 month ago

A patch release gert 2.1.0 is now on CRAN.