Home > Blockchain >  Rstudio unable to install 'psimetrica-R' package from Github
Rstudio unable to install 'psimetrica-R' package from Github

Time:06-15

I am unable to install a package on Github using Rstudio (version 4.0.4). The package is here: https://github.com/stmueller/psimetrica-R

I've tried to install directly from console with the following:

install.packages("psimetrica-R", repos = "https://github.com/stmueller/psimetrica-R.git")

which causes Rstudio to print the following error:

Warning in install.packages : unable to access index for repository https://github.com/stmueller/psimetrica-R.git/src/contrib: cannot open URL 'https://github.com/stmueller/psimetrica-R.git/src/contrib/PACKAGES' Warning in install.packages : package ‘psimetrica-R’ is not available for this version of R

A version of this package for your version of R might be available elsewhere, see the ideas at https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages Warning in install.packages : unable to access index for repository https://github.com/stmueller/psimetrica-R.git/bin/windows/contrib/4.0: cannot open URL 'https://github.com/stmueller/psimetrica-R.git/bin/windows/contrib/4.0/PACKAGES'

I also tried:

devtools::install_github("stmueller/psimetrica-R")

which causes:

Error: Failed to install 'unknown package' from GitHub: HTTP error 404. Not Found

Did you spell the repo owner (stmueller) and repo name (psimetrica-R) correctly? If spelling is correct, check that you have the required permissions to access the repo.

I've also tried downloading the ZIP file from the repo page and installing with:

install.packages("C:/Users/lyamm/Downloads/psimetrica-R-master.zip", repos = NULL, type = "win.binary")

which causes...

Installing package into ‘C:/Users/lyamm/Documents/R/win-library/4.0’ (as ‘lib’ is unspecified) Warning in install.packages : cannot open compressed file 'psimetrica-R-master/DESCRIPTION', probable reason 'No such file or directory' Error in install.packages : cannot open the connection

Am I doing something wrong? Or is there a problem with / missing files in the package itself?

CodePudding user response:

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.

  • Related