r-lib / gert

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

gert wont install on CentOS 7 #129

Closed baderstine closed 3 years ago

baderstine commented 3 years ago
> install.packages("gert")
trying URL 'https://repo.miserver.it.umich.edu/cran/src/contrib/gert_1.2.0.tar.gz'
Content type 'application/octet-stream' length 66100 bytes (64 KB)
==================================================
downloaded 64 KB

* installing *source* package ‘gert’ ...
** package ‘gert’ successfully unpacked and MD5 sums checked
** using staged installation
> curl::curl_download("https://r-lib.github.io/gert/get-libgit2-linux.sh","get-libgit2-linux.sh")
> 
> 
> curl::curl_download('https://r-lib.github.io/gert/libgit2-1.1.0.x86_64_legacy-linux.tar.gz','bundle.tar.gz')
> 
> 
Using static libgit2-1.1.0 for Linux x86_64
Using PKG_CFLAGS=-DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include
Using PKG_LIBS=-L/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/lib -lgit2 -lrt -lpthread -lssh2 -lssl -lcrypto -ldl -lpcre -lz
Configuration OK!
** libs
rm -f gert.so branch.o clone.o commit.o config.o conflicts.o files.o init.o merge.o rebase.o stash.o submodules.o tag.o utils.o version.o
gcc -std=gnu99 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -c branch.c -o branch.o
gcc -std=gnu99 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -c clone.c -o clone.o
gcc -std=gnu99 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -c commit.c -o commit.o
gcc -std=gnu99 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -c config.c -o config.o
gcc -std=gnu99 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -c conflicts.c -o conflicts.o
gcc -std=gnu99 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -c files.c -o files.o
gcc -std=gnu99 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -c init.c -o init.o
gcc -std=gnu99 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -c merge.c -o merge.o
gcc -std=gnu99 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -c rebase.c -o rebase.o
gcc -std=gnu99 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -c stash.c -o stash.o
gcc -std=gnu99 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -c submodules.c -o submodules.o
gcc -std=gnu99 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -c tag.c -o tag.o
gcc -std=gnu99 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -c utils.c -o utils.o
gcc -std=gnu99 -I"/opt/R/4.0.4/lib/R/include" -DNDEBUG -DSTATIC_LIBGIT2 -I/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/include -DR_NO_REMAP -DSTRICT_R_HEADERS  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -c version.c -o version.o
gcc -std=gnu99 -shared -L/opt/R/4.0.4/lib/R/lib -L/usr/local/lib -o gert.so branch.o clone.o commit.o config.o conflicts.o files.o init.o merge.o rebase.o stash.o submodules.o tag.o utils.o version.o -L/tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/lib -lgit2 -lrt -lpthread -lssh2 -lssl -lcrypto -ldl -lpcre -lz -L/opt/R/4.0.4/lib/R/lib -lR
/bin/ld: /tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/lib/libgit2.a(annotated_commit.c.o): unrecognized relocation (0x2a) in section `.text'
/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make: *** [gert.so] Error 1
ERROR: compilation failed for package ‘gert’
* removing ‘/opt/R/4.0.4/lib/R/library/gert’

The downloaded source packages are in
    ‘/tmp/RtmpIBZXzm/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("gert") :
  installation of package ‘gert’ had non-zero exit status

Clearly there's some error here, which seems to be a problem related to libgit2:

/bin/ld: /tmp/RtmplticrS/R.INSTALL2a297da3f6cf/gert/libgit2/lib/libgit2.a(annotated_commit.c.o): unrecognized relocation (0x2a) in section `.text'
/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make: *** [gert.so] Error 1

...but I have no idea what to do about it. "gert" is required by "usethis" which is required by "devtools", so I cannot install devtools which is what I ultimately am trying to do.

jeroen commented 3 years ago

What do you get in the shell when you do

which gcc
gcc --version

I suspect you have an outdated compiler. A workaround would be to install:

sudo yum install libgit2-devel

And then in R:

Sys.setenv(USE_SYSTEM_LIBGIT2=1)
install.packages("gert")
baderstine commented 3 years ago

I did try sudo yum install libgit2-devel already.

which gcc
/usr/bin/gcc

gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

and

ld --version
GNU ld version 2.25.1-32.base.el7_4.1 
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
jeroen commented 3 years ago

Are you tied to an old subrelease of centos 7? In my centos 7.9 container I see:

[root@906e90a43fa5 ~]# ld --version
GNU ld version 2.27-44.base.el7
Copyright (C) 2016 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
[root@906e90a43fa5 ~]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

So I think you can solve the problem either by updating to CentOS 7.9, or using the USE_SYSTEM_LIBGIT2 workaround above.

baderstine commented 3 years ago

After trying Sys.setenv(USE_SYSTEM_LIBGIT2=1) in R

install.packages now has a different error:

** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘gert’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/opt/R/4.0.4/lib/R/library/00LOCK-gert/00new/gert/libs/gert.so':
  /lib64/libgit2.so.26: undefined symbol: libssh2_userauth_publickey_frommemory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/opt/R/4.0.4/lib/R/library/gert’
baderstine commented 3 years ago

updated to gcc 4.8.5 20150623 (Red Hat 4.8.5-44). That alone did not work. After upgrading, your workaround also did not work (same dyn.load error as my previous comment).

So I ran sudo yum install binutils which updated ld to the newer version, and after that the normal install.packages("gert") worked just fine.

Somehow I figured that out from the comments about binutils this post: https://stackoverflow.com/questions/52737698/unable-to-compile-unrecognized-relocation-0x2a-in-section-text

jeroen commented 3 years ago

Thanks for the update. There must have been some bugfix in binutils at some point between the 2014 and 2016 version 🤷 . Glad you got it fixed.

Landau1994 commented 3 years ago

updated to gcc 4.8.5 20150623 (Red Hat 4.8.5-44). That alone did not work. After upgrading, your workaround also did not work (same dyn.load error as my previous comment).

So I ran sudo yum install binutils which updated ld to the newer version, and after that the normal install.packages("gert") worked just fine.

Somehow I figured that out from the comments about binutils this post: https://stackoverflow.com/questions/61646933/how-to-update-to-specific-r-version-on-linux-red-hat-centos-keeping-the-previ

That's work for me, thanks!