简体   繁体   中英

Ubuntu, how to deal the error "<stdin>:1:10: fatal error: git2.h: No such file or directory"?

I am trying to install the easypackages R package on R 3.6.1 on miniconda, which requires the installation of the gert package, that fails. Here's the log:

* 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
----------------------------- 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.
----------------------------------------------------------------------
ERROR: configuration failed for package ‘gert’
* removing ‘/home/dave/miniconda3/envs/r-environment/lib/R/library/gert’
ERROR: dependency ‘gert’ is not available for package ‘usethis’
* removing ‘/home/dave/miniconda3/envs/r-environment/lib/R/library/usethis’
ERROR: dependency ‘usethis’ is not available for package ‘devtools’
* removing ‘/home/dave/miniconda3/envs/r-environment/lib/R/library/devtools’
ERROR: dependency ‘devtools’ is not available for package ‘easypackages’
* removing ‘/home/dave/miniconda3/envs/r-environment/lib/R/library/easypackages’

The downloaded source packages are in
    ‘/tmp/RtmpsVDMkh/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning messages:
1: In install.packages(new.packages, repos = "http://cran.us.r-project.org") :
  installation of package ‘gert’ had non-zero exit status
2: In install.packages(new.packages, repos = "http://cran.us.r-project.org") :
  installation of package ‘usethis’ had non-zero exit status
3: In install.packages(new.packages, repos = "http://cran.us.r-project.org") :
  installation of package ‘devtools’ had non-zero exit status
4: In install.packages(new.packages, repos = "http://cran.us.r-project.org") :
  installation of package ‘easypackages’ had non-zero exit status
Error in library("easypackages") : 
  there is no package called ‘easypackages’
Execution halted

I already installed the libgit2-dev Ubuntu package but it did not solve the problem. Any suggestion on how to fix it? I am using an Ubuntu 16.04.7 LTS operating system.

Not an answer to Ubuntu but might help other debug. Had a similar error when installing package 'devtools' in R 4.1.1 on Mac 10.15.7 Catalina. running brew install libgit2 solved the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM