Configuration failed to find libgit2 library

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?

If you’re linking against a C library, you need to install its development Apt package:

addons:
  apt:
    packages:
      - libgit2-dev

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.

Maybe before, it happened to be preinstalled. In other topics, you can see plenty of cases where people install Apt development packages.

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…

@jeroen and @jimhester
I have a similar problem with a package (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.

You can try adding this to your .travis.yml

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

Worked perfectly. Thank you.

Now to get the Apple build to work