user468311
user468311

Reputation:

How do I force installation of R package from custom repo?

There's a dependency of dependency which fails to compile when pulled from CRAN at the moment, so the maintainer provided an alternative Cannot compile RcppArmadillo.

I've tried to install RcppArmadillo from that path like so:

if(!require("RcppArmadillo")) install.packages("RcppArmadillo", repos="https://rcppcore.github.io/drat", lib = LIB_PATH)
library(RcppArmadillo)

if(!require("sqjin/scAI")) devtools::install_github("sqjin/scAI", lib = LIB_PATH)
library(scAI, lib.loc = LIB_PATH)

However, I can see in the logs that RcppArmadillo is still being pulled from CRAN.

How do I force the installation from custom repo?

Upvotes: 2

Views: 639

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368221

By setting your options("repos") (named vector) argument in one of your (user or system) startup files you make the alternate location known to R. After that R will pick the highest (== "newest") version (number).

Here is a block from help(Startup) showing one way to do it:

 ## Example of Rprofile.site
 local({
   # add MASS to the default packages, set a CRAN mirror
   old <- getOption("defaultPackages"); r <- getOption("repos")
   r["CRAN"] <- "http://my.local.cran"
   options(defaultPackages = c(old, "MASS"), repos = r)
   ## (for Unix terminal users) set the width from COLUMNS if set
   cols <- Sys.getenv("COLUMNS")
   if(nzchar(cols)) options(width = as.integer(cols))
   # interactive sessions get a fortune cookie (needs fortunes package)
   if (interactive())
     fortunes::fortune()
 })

where you could just use

   r["CRAN"] <- "https://cloud.r-project.org"
   r["Rcpp"] <- "https://RcppCore.github.io/drat"

As the RcppCore repo is a drat repo you could also consult the drat documentation which has other examples and helpers.

Upvotes: 2

Related Questions