Evelyn Yang
Evelyn Yang

Reputation: 13

Unable to install rmarkdown packages

Here's what I got...

** Installing R Package Dependencies for R Markdown: 'rmarkdown', 'stringi'
[1/2] Installing rmarkdown...
trying URL 'http://cran.rstudio.com/src/contrib/rmarkdown_2.9.tar.gz'
Content type 'application/x-gzip' length 3246617 bytes (3.1 MB)
================================================[2/2] Installing stringi...

downloaded 3.0 MB

Error in download.file(url, destfile, method, mode = "wb", ...) : 
  download from 'http://cran.rstudio.com/src/contrib/rmarkdown_2.9.tar.gz' failed
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
  downloaded length 3152276 != reported length 3246617

2: In download.file(url, destfile, method, mode = "wb", ...) :
  URL 'http://cran.rstudio.com/src/contrib/rmarkdown_2.9.tar.gz': Timeout of 60 seconds was reached

Warning in download.packages(pkgs, destdir = tmpd, available = available,  :
  download of package ‘rmarkdown’ failed

trying URL 'http://cran.rstudio.com/bin/macosx/contrib/4.1/stringi_1.7.3.tgz'
Content type 'application/x-gzip' length 14636855 bytes (14.0 MB)

=========
downloaded 2.7 MB

Error in download.file(url, destfile, method, mode = "wb", ...) : 
  download from 'http://cran.rstudio.com/bin/macosx/contrib/4.1/stringi_1.7.3.tgz' failed
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
  downloaded length 2835937 != reported length 14636855

2: In download.file(url, destfile, method, mode = "wb", ...) :
  URL 'http://cran.rstudio.com/bin/macosx/contrib/4.1/stringi_1.7.3.tgz': Timeout of 60 seconds was reached
Warning in download.packages(pkgs, destdir = tmpd, available = available,  :
  download of package ‘stringi’ failed

Upvotes: 1

Views: 2033

Answers (2)

r2evans
r2evans

Reputation: 161110

You can stop all of that output after the first mention of Timeout of 60 seconds was reached. It appears you are experiencing network glitches, and R is not adapting to them well.

Three suggestions:

  • increase R's timeout, per @Phil's answer;
  • keep trying with install.packages(..) until it finally works, hoping luck will eventually smile on you; or
  • download externally, verify the files downloaded, then install manually.

Assuming the third, then using firefox/chrome/safari (or whatever you prefer), download the URLs present in your R console manually to a directory. I'll assume the local directory, but you can save them to where-ever you prefer.

AP <- available.packages()
AP[AP[,1] %in% c("rmarkdown", "stringi"),c("Package", "Version", "MD5sum", "Repository")]
#           Package     Version MD5sum                             Repository                            
# rmarkdown "rmarkdown" "2.9"   "acd82da6a09f8e6564595dfa9039e032" "https://cran.rstudio.com/src/contrib"
# stringi   "stringi"   "1.7.3" "94c37221840cd9f5b7545c585d0c6b07" "https://cran.rstudio.com/src/contrib"
system("md5sum rmarkdown_2.9.tar.gz")
# acd82da6a09f8e6564595dfa9039e032 *rmarkdown_2.9.tar.gz
# [1] 0

(and repeat for stringi).

Assuming that the checksums match, then you can do

install.packages(c("rmarkdown_2.9.tar.gz", "stringi_1.7.3.tgz"), repos = NULL)

to install the downloaded files.

Upvotes: 1

Phil
Phil

Reputation: 4444

The error is that the timeout of 60 seconds is reached (i.e. it's taking too long to download). A workaround is to increase the timeout time:

options(timeout=120)

Or maybe longer if you need it

Upvotes: 1

Related Questions