There is an R option for repos
.
When installing a package you can provide a repos
param, and I assumed it overrides getOption("repos")
. But from testing, it seems that's not true.
For example:
options(repos=c(CRAN="https://BADNAME.com"))
install.packages("vctrs", repos = "https://cloud.R-project.org")
With this code, I would assume that the BADNAME repo would be completely ignored because I explicitly provided a repos argument. But after running this code, I learned this is not the case.
To me that feels like a bug. The repos
argument intuitively means that it would be what's used, it should override environment settings. Why is this not the case?
1 Like
FJCC
June 13, 2023, 7:25pm
2
I don't know if it matters, but the url is spelled with a lower case r https://cloud.r-project.org
That's true, thanks. Although it's not relevant to the question itself, of "why is getOption('repos') not ignored"
I was able to replicate this on my local machine and found that when I was explicit with the namespace, it worked as expected
options(repos=c(CRAN="https://BADNAME.com"))
utils::install.packages("vctrs", repos = "https://cloud.r-project.org")
That's a very interesting observation. Now it's even more of a mystery!
I believe this is a bug in RStudio. The observation that namespacing from {utils} and that running the code in a terminal works shows that it's an RStudio issue. install.packages(repos = X) from RStudio does not override the repos R option · Issue #13247 · rstudio/rstudio · GitHub
system
Closed
July 27, 2023, 5:56pm
7
This topic was automatically closed 42 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.