Can't install packages from any mirror in RStudio; works in R

rstudio

#1

I can install any package from the R executable. But from RStudio, I get

Warning in install.packages :
  unable to access index for repository http://cran.rstudio.com/src/contrib:
  cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
Warning in install.packages :
  unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
  cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'

Yes, these are warnings not errors, but nothing is installed anyway.
I can change the repository e.g. with

install.packages('qgam', dependencies=TRUE, repos='http://cran.rstudio.com/')

or in the RStudio settings, but nothing makes any difference.

I have uninstalled R and Rstudio, deleted the Rstudio-desktop folder, deleted all .Renviron files, then reinstalled R and Rstudio. I have checked and unchecked “Use internet explorer library” and everything else I can find.

.libPaths() gives “C:/Users/User/Documents/R/win-library/3.4” “C:/Program Files/R/R-3.4.3/library” which seems fine, only the first is writeable to Rstudio, but that should be OK?

There are no firewalls in operation.

This is driving me nuts.

R and Rstudio are up to date, i.e. R is 3.4.3, Rstudio is 1.1.423

I posted this question on stackoverflow but no replies. https://stackoverflow.com/questions/48751027/cant-install-packages-from-any-mirror-in-rstudio-works-in-r


#2

Any chance you have an antivirus / firewall / other piece of software that might be preventing RStudio from contacting the CRAN servers?


#3

thanks, it was Bitdefender - it didn’t use to do this, must have been an update to Bitdefender. I had to add R and RStudio (“protection” screen, click Features, click the settings gear-wheel in the Firewall section, click “Add rule” and then same again for “Application Access” in the “safe files” section of the Features screen.


#4

Glad you were able to find the culprit! These kinds of issues can definitely be frustrating, but hopefully this will also give clues to any future user who bumps into the same problem.