Cannot Install an R Package from Github

R Unable to Install Packages From GitHub (System Error 267 @win/processx.c:1040)

The standalone mode of the remotes package solved the issue for me,
as suggested by the maintainer of processx (Gábor Csárdi) here

devtools::install_github() only calls remotes::install_github().

However, for the remotes, there is the option to be exectued in standalone mode

Source: Cran

Standalone mode

remotes will use the curl, git2r and pkgbuild packages if they are
installed to provide faster implementations for some aspects of the
install process. However if you are using remotes to install or update
these packages (or their reverse dependencies) using them during
installation may fail (particularly on Windows).

If you set the environment variable R_REMOTES_STANDALONE="true" (e.g.
in R Sys.setenv(R_REMOTES_STANDALONE="true")) you can force remotes to
operate in standalone mode and use only its internal R
implementations. This will allow successful installation of these
packages

With the following lines of code, gt was finally successfull installed from github.

Sys.setenv(R_REMOTES_STANDALONE="true")
remotes::install_github("rstudio/gt")

Thanks all the commentators for your help!

Update October / 2021

To avoid having to do these steps (Set in standanlone mode, and install with remotes) over and over again everytime you want to install a new package from github another convenient workaround is to just rollback to the previous version of processx as adviced by @rempsy in the github issue:

install.packages("pacman")
pacman::p_del(processx)
# Installing previous verison 3.5.1
install.packages("https://cran.r-project.org/src/contrib/Archive/processx/processx_3.5.1.tar.gz", repos=NULL, type="source")

After the rollback of processx to version 3.5.1, devtools::install_github() works as expected, e.g.

devtools::install_github("rstudio/gt")

Rstudio unable to install 'psimetrica-R' package from Github

A github source repository is not an R package repository like CRAN -- so you cannot use install.packages().

Instead, use remotes::install_gihub() as in

if (!requireNamespace("remotes", quietly=TRUE)) install.packages("remotes")
remotes::install_github("stmueller/psimetrica-R")

This will install remotes if needed, and use it to install the desired package.

Or, at least, that would work in principle if psimetrica-R was a regular R source package. Here it fails because of its layout:

> remotes::install_github("stmueller/psimetrica-R")
Error: Failed to install 'unknown package' from GitHub:
cannot open URL 'https://api.github.com/repos/stmueller/psimetrica-R/contents/DESCRIPTION?ref=HEAD'
>

So you could fork the repo and make it proper package first. At least open source lets you do that.

Error when trying to install package from GitHub

You have not yet created a package. You've just created some files with R code in them. An R package has a very particular structure that includes things like a DESCRIPTION file and a NAMESPACE file. In theory you could create these yourself, but often it's easier to use things like devtools::create and roxygen to create them for you. Or if you are using RStudio, you can create a new R Package project with default versions of these files.

To add a DESCRIPTION File, try running

usethis::use_description()

That will fill in defaults you can change.

Then you will need to create a NAMESPACE file. If you just want to make all the functions you define inside your R files to be available outside the pacakge, you can just put

exportPattern("^[[:alpha:]]+")

in that file and that should work.

You might also consider following guides like thoses http://r-pkgs.had.co.nz/package.html or https://swcarpentry.github.io/r-novice-inflammation/08-making-packages-R/ for a better overview on creating a package.

Once your repo looks like a proper R package, then you can use devtools::install_github to install it.

Note that github can be useful for tracking changes to any types of files. You may perform an analysis in an R script that you would like to track changes for and save that on github but it may not make sense to turn that analysis script into a packages. You generally make packages when you want to reuse functions or data across different projects then those projects can install and load your package. So not all R code lives inside an R package, but devtools::install_github can only be used to install actual packages.

R package doesn't install from github

In order to install this package, I had to install this:JDK 13
https://www.oracle.com/java/technologies/javase-jdk13-downloads.html

This allowed each of the packages to be installed correctly.



Related Topics



Leave a reply



Submit