unable to access index for repository and cannot change CRAN Mirror

Hello!

I have been trying to install R packages onto my work machine but I have not been able to do so! I am running R 3.6.3 on Mac OS Mojave. I've looked at other posts and even after putting my http proxy setting onto the .Renviron file i keep getting the same errors. When I try to select a different mirror I get an erro saying it cannot connect to the mirror. I have been stuck with this issue for several days and I am unsure what to do. Can anyone help?
I tried the same things in my personal computer and it worked so I assume it has to do with proxy or firewall. But even after setting proxies I cannot get past this.

Error when trying to install

> 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://cran.rstudio.com/src/contrib:
>   cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
> Warning in install.packages :
>   package ‘data.table’ is not available (for R version 3.6.3)
> Warning in install.packages :
>   unable to access index for repository http://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6:
>   cannot open URL 'http://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/PACKAGES'

Error when choosing other mirror

> Warning message:
> In download.file(url, destfile = f, quiet = TRUE) :
>   URL 'https://cran.r-project.org/CRAN_mirrors.csv': status was 'HTTP response code said error'

Can you give more details on how are you doing this? In .Renviron you can set environmental variables but as far as I know, R is not going to automatically set the proxy config from them, are you running any additional code for this purpose?

Hello,

To try to solve this issue I am only trying to do this directly by doing install.packages("data.table") after starting RStudio. I check the Sys.getenv() and my variable values are there. What other info do you need me to provide?

It is not enough to set your credentials in your environment, as I said, R is not going to automatically set the proxy settings from that, you have to do it manually with something like this

library(httr)
set_config(
  use_proxy(url="your.proxy.ip", port="port", username="user",password="password")
)

Got it thanks for the info! I was able to solve my issue my disconnecting from the VPN. I had tried that before and it had not been able to work. Reason why is that I did not know I also had to remove the proxy environment variables I had originally set. Thanks for the help though!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.