markhogue
markhogue

Reputation: 1179

Warning in install.packages: unable to access index for repository

After installing R version 4.2.0, I was suddenly unable to install packages from CRAN. This was only true from my office site which has a strong firewall.

Warning message pasted below:

> 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' Installing package into
> ‘C:/Users/l2863/AppData/Local/R/win-library/4.2’ (as ‘lib’ is
> unspecified) 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'

I reviewed the similar questions and did not find any solutions that worked.

Upvotes: 9

Views: 57449

Answers (3)

Arthur Yip
Arthur Yip

Reputation: 6230

Try installing packages through the R application instead of RStudio.

Upvotes: 1

Rola
Rola

Reputation: 1946

I found a solution here , it worked with me using R studio on Windows

Go to Tools -> Global Options -> Packages-> Management Tab-> Uncheck "Use secure download method for HTTP"

enter image description here

However, if you prefer to maintain https connection for installing R packages, please refer to this link for more details

If you have this option enabled and still receive a warning message it’s likely you need to select an alternate CRAN mirror that supports HTTPS. Mirrors currently known to support HTTPS are enumerated below in Secure CRAN Mirrors. It’s also possible that you’ve manually specified a download method or CRAN mirror in your .Rprofile that doesn't support secure downloads

Upvotes: 15

markhogue
markhogue

Reputation: 1179

Installing CRAN packages was restored by going into the Rstudio global options and setting the Primary CRAN repository to USA (TX 1) [https] - Revolution Analytics, Dallas, TX.

I don't know why this worked, whereas selecting USA (TN) [https] - National Institute for Computational Sciences, Oak Ridge did not work.

My company's cyber security engineer stated that the TX location "seemingly points to one specific location, unlike the others."

Upvotes: 3

Related Questions