[R] Why install.packages(repos = X) does not override the 'repos' R option?

Dean Attali d@@tt@|| @end|ng |rom gm@||@com
Wed Jun 14 15:22:27 CEST 2023


There is a default R option for which repos to install from -
`getOption("repos")`.

When installing a package using install.packages(), you can provide a
`repos` parameter. The default value of that parameter is
`getOption("repos")`. I assumed that this parameter would override the R
option. In other words, I assumed that if the parameter is provided, then
the R option would not even be looked at. But after testing this, it seems
this is not the case.

For example, running the following two lines in an R session:

options(repos=c(CRAN="https://BADNAME.com"))
install.packages("vctrs", repos = "https://cloud.R-project.org")

I would have expected the first line to be rendered meaningless, but in
fact after running the second line I see errors about the BADNAME
repository. This feels like a bug to me, but I'm sure there's a reason
behind this. Does anyone know why this is the case?

	[[alternative HTML version deleted]]



More information about the R-help mailing list