admin管理员组

文章数量:1025521

I was using remote server as a non-root user and trying to do some single cell analysis. When I installed R package 'devtools' simply using install.packages("devtools") I got dozens of error info. At first I got

Error in curl::curl_download(".sh", : 
SSL connect error [r-lib.github.io]: Recv failure: Connection reset by peer

Then I got

Found pkg-config cflags and libs!
Using PKG_CFLAGS=
Using PKG_LIBS=-L/usr/local/lib64 -lgit2

Both of them led to

<stdin>:1:10: fatal error: git2.h: No such file or directory
compilation terminated.

I was using remote server as a non-root user and trying to do some single cell analysis. When I installed R package 'devtools' simply using install.packages("devtools") I got dozens of error info. At first I got

Error in curl::curl_download("https://r-lib.github.io/gert/get-libgit2-linux.sh", : 
SSL connect error [r-lib.github.io]: Recv failure: Connection reset by peer

Then I got

Found pkg-config cflags and libs!
Using PKG_CFLAGS=
Using PKG_LIBS=-L/usr/local/lib64 -lgit2

Both of them led to

<stdin>:1:10: fatal error: git2.h: No such file or directory
compilation terminated.
Share Improve this question edited Nov 19, 2024 at 2:13 Nicolas Fong asked Nov 18, 2024 at 10:40 Nicolas FongNicolas Fong 113 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

I finally installed it and here is what I've tried

At first, I got

* installing *source* package ‘gert’ ...
** package ‘gert’ successfully unpacked and MD5 sums checked
** using staged installation
Error in curl::curl_download("https://r-lib.github.io/gert/get-libgit2-linux.sh",  : 
  SSL connect error [r-lib.github.io]: Recv failure: Connection reset by peer
Calls: <Anonymous> -> raise_libcurl_error
Execution halted
Using PKG_CFLAGS=
Using PKG_LIBS=-lgit2
----------------------------- ANTICONF -------------------------------
Configuration failed to find libgit2 library. Try installing:
 * brew: libgit2 (MacOS)
 * deb: libgit2-dev (Debian, Ubuntu, etc)
 * rpm: libgit2-devel (Fedora, CentOS, RHEL)
If libgit2 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libgit2.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
-------------------------- [ERROR MESSAGE] ---------------------------
<stdin>:1:10: fatal error: git2.h: No such file or directory
compilation terminated.

I noticed the message If libgit2 is already installed, check that 'pkg-config' is in your PATH and PKG_CONFIG_PATH contains a libgit2.pc file. So I searched my own dir but there wasn't the ‘libgit2.pc’ file.

Then I googled libgit2 and found its github releases in https://github/libgit2/libgit2/releases. I downloaded the latest version and built it following the installation guide. After that I got libgit2.so and libgit2.pc. Then I assigned the pkgconfig dir with export PKG_CONFIG_PATH=/home/fangyy/miniconda3/envs/r4.4.1/lib/pkgconfig/ and copied libgit2.pc to it, as well as copy .so files to specified lib dir (as I was non-root user). After that, I runed the 'install.packages()' and got sligthly different error info:

* 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=-L/usr/local/lib64 -lgit2 
----------------------------- ANTICONF -------------------------------
Configuration failed to find libgit2 library. Try installing:
 * brew: libgit2 (MacOS)
 * deb: libgit2-dev (Debian, Ubuntu, etc)
 * rpm: libgit2-devel (Fedora, CentOS, RHEL)
If libgit2 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libgit2.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
-------------------------- [ERROR MESSAGE] ---------------------------
<stdin>:1:10: fatal error: git2.h: No such file or directory
compilation terminated.

This time, pkg-config was found, which means the ’libgit2.pc' file worked I guess. But the using PKG_LIBS wasn't the lib dir I assigned. The words If pkg-config is unavailable you can set INCLUDE_DIR and LIB_DIR manually via: R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...' reminded me. I realized that I could set the lib path in install.packges(). So I tried:

install.packages("gert", configure.vars='INCLUDE_DIR=/home/fangyy/software/libgit2-1.8.4/include LIB_DIR=/home/fangyy/miniconda3/envs/r4.4.1/lib/')

Eventually, gert was installed and so was devtools

This experience teached me a lot. The most important thing I think is when a dependency library file wasn't in the /usr/lib, build it ourselves and assign the path we built lib file when installing may be an effective choice.

I was using remote server as a non-root user and trying to do some single cell analysis. When I installed R package 'devtools' simply using install.packages("devtools") I got dozens of error info. At first I got

Error in curl::curl_download(".sh", : 
SSL connect error [r-lib.github.io]: Recv failure: Connection reset by peer

Then I got

Found pkg-config cflags and libs!
Using PKG_CFLAGS=
Using PKG_LIBS=-L/usr/local/lib64 -lgit2

Both of them led to

<stdin>:1:10: fatal error: git2.h: No such file or directory
compilation terminated.

I was using remote server as a non-root user and trying to do some single cell analysis. When I installed R package 'devtools' simply using install.packages("devtools") I got dozens of error info. At first I got

Error in curl::curl_download("https://r-lib.github.io/gert/get-libgit2-linux.sh", : 
SSL connect error [r-lib.github.io]: Recv failure: Connection reset by peer

Then I got

Found pkg-config cflags and libs!
Using PKG_CFLAGS=
Using PKG_LIBS=-L/usr/local/lib64 -lgit2

Both of them led to

<stdin>:1:10: fatal error: git2.h: No such file or directory
compilation terminated.
Share Improve this question edited Nov 19, 2024 at 2:13 Nicolas Fong asked Nov 18, 2024 at 10:40 Nicolas FongNicolas Fong 113 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

I finally installed it and here is what I've tried

At first, I got

* installing *source* package ‘gert’ ...
** package ‘gert’ successfully unpacked and MD5 sums checked
** using staged installation
Error in curl::curl_download("https://r-lib.github.io/gert/get-libgit2-linux.sh",  : 
  SSL connect error [r-lib.github.io]: Recv failure: Connection reset by peer
Calls: <Anonymous> -> raise_libcurl_error
Execution halted
Using PKG_CFLAGS=
Using PKG_LIBS=-lgit2
----------------------------- ANTICONF -------------------------------
Configuration failed to find libgit2 library. Try installing:
 * brew: libgit2 (MacOS)
 * deb: libgit2-dev (Debian, Ubuntu, etc)
 * rpm: libgit2-devel (Fedora, CentOS, RHEL)
If libgit2 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libgit2.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
-------------------------- [ERROR MESSAGE] ---------------------------
<stdin>:1:10: fatal error: git2.h: No such file or directory
compilation terminated.

I noticed the message If libgit2 is already installed, check that 'pkg-config' is in your PATH and PKG_CONFIG_PATH contains a libgit2.pc file. So I searched my own dir but there wasn't the ‘libgit2.pc’ file.

Then I googled libgit2 and found its github releases in https://github/libgit2/libgit2/releases. I downloaded the latest version and built it following the installation guide. After that I got libgit2.so and libgit2.pc. Then I assigned the pkgconfig dir with export PKG_CONFIG_PATH=/home/fangyy/miniconda3/envs/r4.4.1/lib/pkgconfig/ and copied libgit2.pc to it, as well as copy .so files to specified lib dir (as I was non-root user). After that, I runed the 'install.packages()' and got sligthly different error info:

* 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=-L/usr/local/lib64 -lgit2 
----------------------------- ANTICONF -------------------------------
Configuration failed to find libgit2 library. Try installing:
 * brew: libgit2 (MacOS)
 * deb: libgit2-dev (Debian, Ubuntu, etc)
 * rpm: libgit2-devel (Fedora, CentOS, RHEL)
If libgit2 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libgit2.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
-------------------------- [ERROR MESSAGE] ---------------------------
<stdin>:1:10: fatal error: git2.h: No such file or directory
compilation terminated.

This time, pkg-config was found, which means the ’libgit2.pc' file worked I guess. But the using PKG_LIBS wasn't the lib dir I assigned. The words If pkg-config is unavailable you can set INCLUDE_DIR and LIB_DIR manually via: R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...' reminded me. I realized that I could set the lib path in install.packges(). So I tried:

install.packages("gert", configure.vars='INCLUDE_DIR=/home/fangyy/software/libgit2-1.8.4/include LIB_DIR=/home/fangyy/miniconda3/envs/r4.4.1/lib/')

Eventually, gert was installed and so was devtools

This experience teached me a lot. The most important thing I think is when a dependency library file wasn't in the /usr/lib, build it ourselves and assign the path we built lib file when installing may be an effective choice.

本文标签: Couldn39t install R package 39devtools39 as 39Configuration failed to find libgit2 library39Stack Overflow