error after installing rtools40 when installing packages

I'm a beginner at R. I have updated R, Rstudio and rtools to the newest version(R for windows 4.0.2, Rstudio1.3.1073, rtools40). I have followed the instructions in https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/Rtools/
while downloading rtools40, I achieved to set the path, however, I ran into trouble while I installed the packages, I hope someone could answer my doubts.
here is my code:

file.edit('~/.Renviron')
writeLines('PATH="{RTOOLS40_HOME}\\usr\\bin;{PATH}"', con = "~/.Renviron")

Restarting R session...

Sys.which("make")
make
"C:\PROGRA~1\R\R-40~1.2\rtools40\usr\bin\make.exe"
install.packages("jsonlite", type = "source")
Warning in install.packages :
unable to access index for repository ...tps://cran.rstudio.com.....:
无法打开URL'...ttps://cran.rstudio.com/...................'
Installing package into ‘C:/Users/asus/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
Warning in install.packages :
unable to access index for repository ...ttps://......................................:
无法打开URL'...ttps://cran.rstudio.com/src...........'
Warning in install.packages :
package ‘jsonlite’ is not available (for R version 4.0.2)

This seems like a connectivity issue, R is not being able to connect to the CRAN repository you have selected, these are some things to try.

  • Choose a different CRAN repository, RStudios repository is a good choice (http://cran.rstudio.com/) or you could choose one that is geographically closer to you.
  • Disable secure download setting.
  • Check if your internet connection has traffic restrictions of some kind, like a firewall, proxy server, etc. This is usually the case when you are at work or school.
1 Like

thank you so much for your reply, I've chosen another cran mirror and disable secure setting, then it worked!!

This topic was automatically closed 7 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.