Question about how `repos` works when installing a package

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:

install.packages("vctrs", repos = "")

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

I don't know if it matters, but the url is spelled with a lower case r

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

utils::install.packages("vctrs", repos = "")

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

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.