Can’t download any package in R recently

It started becoming a real issue because I can’t download any packages in R recently. Here is the error I’m getting:

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’

I tried many solutions I saw online: chose a different CRAN repository, disabled secure download setting, turned off firewall.

Any help?

My guess is that R 3.6 is no longer getting compiled package binaries. It is four years old, with a jump to 4.0 and then 4.1, 4.2 and now 4.3. Binaries should still be available for 4.0 if you do not want to go to the very latest R version.

Are you also on old versions of macOS and RStudio?

1 Like

It is because CRAN moved the binaries for R 3.6.x to another machine. Add the https://cran-archive.r-project.org/ repos to your config, that's where the binaries are now:

❯ R-3.6 -q
❯ dim(available.packages(type = "binary"))
Warning: unable to access index for repository https://cloud.r-project.org/bin/macosx/el-capitan/contrib/3.6:
  cannot open URL 'https://cloud.r-project.org/bin/macosx/el-capitan/contrib/3.6/PACKAGES'
[1]  0 17

❯ options(repos = c(c(OLD="https://cran-archive.r-project.org/"), getOption("repos")))
❯ dim(available.packages(type = "binary") )
Warning: unable to access index for repository https://cloud.r-project.org/bin/macosx/el-capitan/contrib/3.6:
  cannot open URL 'https://cloud.r-project.org/bin/macosx/el-capitan/contrib/3.6/PACKAGES'
[1] 18132    17
2 Likes

The downside to the archive on CRAN is that the binaries are for older versions of packages. For example, ggplot2 is from June 2021.

I tried adding the repos, still giving error.

> install.packages("~/Downloads/msos_1.2.0.tar", type="binary")
Warning in install.packages :
  unable to access index for repository https://cran-archive.r-project.org/src/contrib:
  cannot open URL 'https://cran-archive.r-project.org/src/contrib/PACKAGES'
Warning in install.packages :
  unable to access index for repository http://lib.stat.cmu.edu/R/CRAN/bin/macosx/el-capitan/contrib/3.6:
  cannot open URL 'http://lib.stat.cmu.edu/R/CRAN/bin/macosx/el-capitan/contrib/3.6/PACKAGES'
Warning in install.packages :
  package ‘~/Downloads/msos_1.2.0.tar’ is not available (as a binary package for R version 3.6.3)

Yes unfortunately, I have MacOs 10.13.6 and Rstudio Version 1.3.1093, I downloaded a newer version of R, but Rstudio doesn’t switch. How can I do that?

First, you can install a local binary (!) package like that, but you need to specify repos = NULL and possibly dependencies = FALSE.

Second, you need to add both the cran-archive and the normal cran repo to have both binary and source packages available.

Third, those are not errors, but warnings, and they happen because 1) the cran-archive repo does not have source packages and 2) the cran repo does not have R 3.6. binary packages. They are normal and you can ignore them.

Btw. imo the easiest to install a local binary package plus its dependencies from the repos is using pak:

source("https://pak.r-lib.org/install.R")
pak::repo_add(ARCHIVE = "https://cran-archive.r-project.org/")
# check repos
pak::repo_ping()
pak::pkg_install("local::<path to file>")
2 Likes

Which version of R did you install? If you go to CRAN and click on "Download R for macOS", scroll down to near the bottom and click on "base", just above "contrib". I might start with 4.0.5.

There is conflicting information on which versions of RStudio are compatible with macOS High Sierra (10.13) and I am quite confused. I hope someone with a definitive answer will reply.

1 Like

I was able to download R 4.0.5 and open in Rstudio, but still giving this error and I know they’re warnings not errors but the package I’m trying to download doesn’t show up on my list and I can’t use the functions in it. Please help.

  • installing source package ‘mclust’ ...
    ** package ‘mclust’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    gfortran -mmacosx-version-min=10.13 -fno-optimize-sibling-calls -fPIC -Wall -g -O2 -c dmvnorm.f -o dmvnorm.o
    make: gfortran: Bad CPU type in executable
    make: *** [dmvnorm.o] Error 1
    ERROR: compilation failed for package ‘mclust’
  • removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/mclust’
    Warning in install.packages :
    installation of package ‘mclust’ had non-zero exit status

The downloaded source packages are in
‘/private/var/folders/1z/tzm59gjj6vx53ptkcfrrjqr00000gn/T/RtmpB8FR2g/downloaded_packages’

I downloaded R version 4.2.3 and opened in Rstudio. It’s downloading now!! Thank you!

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.