R | Unable to Install Packages RStudio Issue (SOLUTION)

If you are unable to install packages issue in R Studio, and facing any of the below mentioned error, you have landed on the right page:

Warning in install.packages :
unable to access index for repository https://cran.rstudio.com/src/contrib:
cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
Warning in install.packages :
package ‘PACKAGE NAME’ is not available (for R version 3.6.0)
Warning in install.packages :
unable to access index for repository https://cran.rstudio.com/bin/windows/contrib/3.6:
cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/PACKAGES'

Solution:

Solution 1: Use R code to solve install.package()

Use below command before using install.packages(“PACKAGE NAME”)

options(repos = c(CRAN = “http://cran.rstudio.com”))

install.packages("package name")

Solution 2: Use RStudio

Changing the configuration in R Studio to solve install packages issue.

Go To Tools -> Global option -> Packages. Then uncheck the option “Use secure download method for HTTP”.

problem unable to install package in R Studio solution
RStudio: Tools -> Global option -> Packages
problem unable to install package in R Studio solution
Rstudio: Under Packages uncheck the option“Use secure download method for HTTP”

For other RStudio issues refer to official Troubleshooting Guide here.

Conclusion

I certainly hope that this guide will help people spend less time figuring about package install debugging and leave more time for data analysis and development.

Start your Data Science Journey here.

7 thoughts on “R | Unable to Install Packages RStudio Issue (SOLUTION)”

  1. Greetings! Ꮩery helpful advice within this post! It’s the little
    changes that wiⅼl make the most important changes.
    Many thanks for sharing!

    Reply
  2. still unable to install any package on Rstudio. R version4.2.1.
    > install.packages(“swirl”)
    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/Alka/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’
    Warning in install.packages :
    package ‘swirl’ is not available for this version of R

    A version of this package for your version of R might be available elsewhere,
    see the ideas at
    https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
    Warning in install.packages :
    unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/4.2:
    cannot open URL ‘http://cran.rstudio.com/bin/windows/contrib/4.2/PACKAGES’

    Reply
    • Option 2 worked for me. When I re-enabled secure (HTTPS) downloads, I got the following message in my RStudio console, which suggests something about the certs on my machine:

      You are configured to use the CRAN mirror at https://cran.rstudio.com/. This mirror supports secure (HTTPS) downloads however your system is unable to communicate securely with the server (possibly due to out of date certificate files on your system). Falling back to using insecure URL for this mirror.

      To learn more and/or disable this warning message see the “Use secure download method for HTTP” option in Tools -> Global Options -> Packages.

      Reply
  3. I did try everything: Below is what I am running:

    options(repos=”http://cran.rstudio.com”)
    install.packages(‘tidyverse’, dependencies=TRUE)

    I get the below error:

    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/1030780/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’
    Warning in install.packages :
    package ‘tidyverse’ is not available for this version of R

    A version of this package for your version of R might be available elsewhere,
    see the ideas at
    https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
    Warning in install.packages :
    unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/4.2:
    cannot open URL ‘http://cran.rstudio.com/bin/windows/contrib/4.2/PACKAGES’

    Reply

Leave a Comment

Keytodatascience Logo

Connect

Subscribe

Join our email list to receive the latest updates.

© 2022 KeyToDataScience