Usethis: Github Actions Issue with `gert` installation

Created on 30 Mar 2021  Â·  10Comments  Â·  Source: r-lib/usethis

Main Issue

First thanks for this wonderful usethis package. I'm currently co-developing the maars R package
on github (with @ricfog). We have used usethis to create our R CMD CHECK and tests Github Actions workflows.

They have worked great, but as of today in a separate branch we started getting the following CI tests error with the gert package.


Error message

Installing package into ‘/Users/runner/work/_temp/Library’
(as ‘lib’ is unspecified)
trying URL 'cloud.r-project.org/bin/macosx/contrib/4.0/remotes_2.2.0.tgz'

Content type 'application/x-gzip' length 385641 bytes (376 KB)
The downloaded binary packages are in
==================================================
    /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//Rtmpr1WRMG/downloaded_packages
downloaded 376 KB

gert (NA -> 1.3.0) [CRAN]
Installing 1 packages: gert
Installing package into ‘/Users/runner/work/_temp/Library’
(as ‘lib’ is unspecified)

installing the source package ‘gert’
  There is a binary version available but the source version is later:

     binary source needs_compilation
trying URL 'cloud.r-project.org/src/contrib/gert_1.3.0.tar.gz'
gert  1.2.0  1.3.0              TRUE

Content type 'application/x-gzip' length 66410 bytes (64 KB)
==================================================
downloaded 64 KB

* installing *source* package ‘gert’ ...
** package ‘gert’ successfully unpacked and MD5 sums checked
** using staged installation
Homebrew 3.0.5
Homebrew/homebrew-core (git revision ee84729719; last commit 2021-03-14)
Homebrew/homebrew-cask (git revision aa703eaf8d; last commit 2021-03-14)
Using PKG_CFLAGS=-I/usr/local/opt/libgit2/include
Using PKG_LIBS=-L/usr/local/opt/libgit2/lib -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' file not found

We thought there may be some issues with our commits in this branch causing the error.

Debugging Actions Taken

However, as a basic debugging step, we also re-ran the same GA workflows today on our main branch which also now give the same error, suggesting our new commits are not driving it. (Note: our main branch before today had passed the checks without this gert error, and has none of our new commits in this error branch merged).

Since the issue seems Github Action related, we wanted to check first whether there are
any changes that should be made to the regular usethis::use_github_actions() workflows
from our end?

Sorry if this is not the right place for this, we thought to check here, if any other usethis users were having the same issues. Please feel free to direct us elsewhere as appropriate.

Any help sincerely appreciated.

All 10 comments

I think this is because gert just updated to v1.3.0 on CRAN, but at the moment I type this, macOS binaries are not available for tha version yet. So remotes is trying to build gert from source and that requires a libgit2 system library.

You have a few choices:

  • Wait and this will resolve itself, when CRAN builds the gert binaries for macOS. Highly recommended.
  • Use linux more on GHA, where there's better support for detecting system requirements, like libgit2 here.
  • Install libgit2 on macOS on GHA, as usethis itself does. Reading other package's GHA workflows is a good trick, in general.
  • Use a pak-based GHA workflow (as opposed to remotes). This is what the tidyverse / r-lib team is moving too, but we regard it as a bit beta right now. But pak is smarter about some of these issues about when to install from source or be happy with an older binary. I'm not sure if this alone would solve your current problem.

In any case, there's nothing to be done about this in usethis.

Hi @jennybc ,

Many thanks for your detailed and helpful comments. They are genuinely appreciated.

Wait and this will resolve itself, when CRAN builds the gert binaries for macOS. Highly recommended.

We were going to wait this issue out on our end for a couple of days, so glad to see this is recommended by the pros 😄 .

Install libgit2 on macOS on GHA, as usethis itself does. Reading other package's GHA workflows is a good trick, in general.

This is a great pointer, we will defnitely try and checkout more workflows from other packages going forward.

Use a pak-based GHA workflow (as opposed to remotes). This is what the tidyverse / r-lib team is moving too, but we regard it as a bit beta right now. But pak is smarter about some of these issues about when to install from source or be happy with an older binary. I'm not sure if this alone would solve your current problem.

So personally pak is our preferred local installation method. It would be great to see this switch away from remotes in usethis for GA (as an option), and we will definitely like to move to it ourselves for this package. We will keep track of updates on this from usethis in future releases. We might even brave it and try tweaking our GA workflows ourselves using pak.

Thanks again.

pak-based workflows are already present here:

https://github.com/r-lib/actions/tree/master/examples

which is where usethis gets all of its workflow files. Those are what the tidyverse GHA functions already default to. We just haven't thrown that switch globally yet, but you could certainly decide to start using the pak-based GHA workflows.

workflows are already present here:

https://github.com/r-lib/actions/tree/master/examples

This is an amazing resource, I can imagine this must have taken a lot of team effort. Thanks for sharing @jennybc. We will take a look and adapt accordingly for our existing work.

@jimhester maintains all thise workflows and usethis provides a delivery service 🙂

@jimhester maintains all thise workflows and usethis provides a delivery service 🙂

Amazing - thanks so much @jimhester for your efforts on this!

@jennybc - a quick follow up. The pak workflows are working for us. So thanks for suggesting them! I have some more follow up questions and some ideas on adding some flexibility to these GA workflows in R. Would the R Community channel be best to raise these ideas/questions? I didn't want to take up more of your valued time here.

Yeah I think community is a good place to discuss further. I recommend following the advice here, in the bullet about community:

https://github.com/r-lib/actions#where-to-find-help

Sounds great - thanks again @jennybc!

The CRAN binaries for MacOS have been updated, so the problem should be resolved now.

The CRAN binaries for MacOS have been updated, so the problem should be resolved now.

Thanks @jeroen for your kind help with this, and for the update!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jennybc picture jennybc  Â·  4Comments

malcolmbarrett picture malcolmbarrett  Â·  4Comments

lwjohnst86 picture lwjohnst86  Â·  7Comments

jennybc picture jennybc  Â·  6Comments

jennybc picture jennybc  Â·  4Comments