# Configuration failed to find libgit2 library

**URL:** https://travis-ci.community/t/configuration-failed-to-find-libgit2-library/10906
**Category:** R
**Created:** [December 23, 2020, 5:58pm UTC](https://travis-ci.community/t/configuration-failed-to-find-libgit2-library/10906 "2020-12-23T17:58:37Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![igor](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/igor/32/3553_2.png) [@igor](https://travis-ci.community/u/igor)
#### Post date: [December 23, 2020, 5:58pm UTC](https://travis-ci.community/t/configuration-failed-to-find-libgit2-library/10906/1 "2020-12-23T17:58:37Z")

</div>

My builds started failing recently. I have `devtools` in my `r_packages` list. The build tries to install `devtools`, which depends on `usethis`, which depends on `gert`, which fails to install:

```
* installing *source* package ‘gert’ ...
** package ‘gert’ successfully unpacked and MD5 sums checked
** using staged installation
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:18: fatal error: git2.h: No such file or directory
compilation terminated.
----------------------------------------------------------------------
ERROR: configuration failed for package ‘gert’

```

I have a simple config:

```
language: r
cache: packages
warnings_are_errors: false

r:
  - bioc-release
  - oldrel
  - release
  - devel

r_packages:
  - covr
  - devtools
  - tidyverse
  - shiny

after_success:
  - Rscript -e 'library(covr); codecov()'

```

This is a fairly common package, but this does not seem to be a widespread problem. Why is this error happening for me?

---

<div class="post-metadata">

### Author: ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)
#### Post date: [December 23, 2020, 8:41pm UTC](https://travis-ci.community/t/configuration-failed-to-find-libgit2-library/10906/2 "2020-12-23T20:41:41Z")

</div>

If you’re linking against a C library, you need to [install its development Apt package](https://docs.travis-ci.com/user/languages/r/#apt-packages):

```auto
addons:
  apt:
    packages:
      - libgit2-dev

```

---

<div class="post-metadata">

### Author: ![igor](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/igor/32/3553_2.png) [@igor](https://travis-ci.community/u/igor)
#### Post date: [December 24, 2020, 1:47am UTC](https://travis-ci.community/t/configuration-failed-to-find-libgit2-library/10906/3 "2020-12-24T01:47:14Z")

</div>

That makes sense, but I didn’t have to do that before and it doesn’t seem like other packages that you use devtools do that that either.

---

<div class="post-metadata">

### Author: ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)
#### Post date: [December 24, 2020, 10:38pm UTC](https://travis-ci.community/t/configuration-failed-to-find-libgit2-library/10906/4 "2020-12-24T22:38:23Z")

</div>

Maybe before, it happened to be preinstalled. [In other topics](https://travis-ci.community/search?q=apt%20packages%20category%3A51), you can see plenty of cases where people install Apt development packages.

---

<div class="post-metadata">

### Author: ![andrewyimingchen](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/andrewyimingchen/32/5976_2.png) [@andrewyimingchen](https://travis-ci.community/u/andrewyimingchen)
#### Post date: [January 6, 2021, 8:33am UTC](https://travis-ci.community/t/configuration-failed-to-find-libgit2-library/10906/5 "2021-01-06T08:33:31Z")

</div>

Hi,

I also have the same issue when using R studio on Mac OS to install package “stopwords”, and the error message is exactly the same.

I’m not sure how to resolve it from reading this post, as I have no idea about R configuration and environment…

---

<div class="post-metadata">

### Author: ![rmsharp](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/rmsharp/32/6289_2.png) [@rmsharp](https://travis-ci.community/u/rmsharp)
#### Post date: [March 11, 2021, 3:21pm UTC](https://travis-ci.community/t/configuration-failed-to-find-libgit2-library/10906/6 "2021-03-11T15:21:44Z")

</div>

@jeroen and @jimhester  
I have a similar problem with a package ([github.com/rmsharp/nprcgenekeepr](http://github.com/rmsharp/nprcgenekeepr)) that used to build. I first got the following errors:

- installing _source_ package ‘textshaping’ …  
\*\* package ‘textshaping’ successfully unpacked and MD5 sums checked  
\*\* using staged installation  
Package harfbuzz was not found in the pkg-config search path.  
Perhaps you should add the directory containing `harfbuzz.pc' to the PKG_CONFIG_PATH environment variable No package 'harfbuzz' found Package fribidi was not found in the pkg-config search path. Perhaps you should add the directory containing `fribidi.pc’  
to the PKG\_CONFIG\_PATH environment variable  
No package ‘fribidi’ found

Based on my limited understanding I added the following to my .travis.yml file.  
addons:  
apt:  
packages:  
- harfbuzz  
- fribidi

This did not work and produced the following error message:  
Reading state information…  
E: Unable to locate package harfbuzz  
E: Unable to locate package fribidi  
apt-get.diagnostics  
apt-get install failed

Explanations and suggests are most welcome.

---

<div class="post-metadata">

### Author: ![jeroen](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/jeroen/32/509_2.png) [@jeroen](https://travis-ci.community/u/jeroen)
#### Post date: [March 11, 2021, 4:47pm UTC](https://travis-ci.community/t/configuration-failed-to-find-libgit2-library/10906/7 "2021-03-11T16:47:53Z")

</div>

You can try adding this to your .travis.yml

```auto
addons:
  apt:
    packages:
      - libharfbuzz-dev
      - libfribidi-dev

```

---

<div class="post-metadata">

### Author: ![rmsharp](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/rmsharp/32/6289_2.png) [@rmsharp](https://travis-ci.community/u/rmsharp)
#### Post date: [March 19, 2021, 7:58pm UTC](https://travis-ci.community/t/configuration-failed-to-find-libgit2-library/10906/9 "2021-03-19T19:58:42Z")

</div>

Worked perfectly. Thank you.

Now to get the Apple build to work
