Failed to install required package to run R Markdown

To run R Markdown I get a pop-up message that the required package 'stringi' needs to be updated; but while the error message returned says installation has failed, right below that it says its been successfully installed too.
I try running R Markdown again after and it still pop-ups about the 'stringi' package needing an update.

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/stringi_1.7.12.zip'
Content type 'application/zip' length 14221653 bytes (13.6 MB)
=======
downloaded 2.0 MB

Error in download.file(url, destfile, method, mode = "wb", ...) : 
  download from 'https://cran.rstudio.com/bin/windows/contrib/4.2/stringi_1.7.12.zip' failed
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
  downloaded length 2118058 != reported length 14221653
2: In download.file(url, destfile, method, mode = "wb", ...) :
  URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/stringi_1.7.12.zip': Timeout of 60 seconds was reached
Warning in download.packages(pkgs, destdir = tmpd, available = available,  :
  download of package 'stringi' failed


✔ Package 'stringi' successfully installed.

Hello,

Did this happen when you ran

install.packages("stringi")

What is the stringi version after you have done this? Look in the packages tab in RStudio.

Grtz,
PJ

I cannot tell for sure but it is likely that the older version of 'stringi" is already loaded and the new version cannot be installed over the loaded library. I would suggest completely shutting down R and RStudio and starting over with a clean environment.

According to the packages tab there isn't any version of stringi installed yet, but it's trying to install v1.7.12. I think I found the culprit through. When I attempted to install stringi package again today, it's now giving me more info about the failed install than it was last night. :woman_shrugging:t3: lol

> install.packages("stringi")
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/src/contrib:
  download from 'https://cran.rstudio.com/src/contrib/PACKAGES' failed
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/s_mar/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/stringi_1.7.12.zip'
Content type 'application/zip' length 14221653 bytes (13.6 MB)
downloaded 303 KB

Warning in install.packages :
  downloaded length 310733 != reported length 14221653
Warning in install.packages :
  URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/stringi_1.7.12.zip': Timeout of 60 seconds was reached
Error in download.file(url, destfile, method, mode = "wb", ...) : 
  download from 'https://cran.rstudio.com/bin/windows/contrib/4.2/stringi_1.7.12.zip' failed
Warning in install.packages :
  download of package ‘stringi’ failed

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. This might help when some download methods are not available in your system.
  • 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.

Aha! You must be on Windows. I am on Linux and don't use Rtools but I think this may help. install.Rtools function - RDocumentation. If not googling for "install Rtools" should find a lot of advise. (Some of which may be useful)

Installing RTools is a good thing to do anyways but it is not relevant in this specific case since there are already Windows binaries for stringi 1.7.12 available on CRAN so no compilation is required.

Then why is the OP getting that error message? Perhaps they need to change repositories?

I have escaped Windows ~15 years ago so I often do not understand what it is doing.

As I said, it seems like a connectivity issue (notice the size difference between what gets downloaded and the reported file size) but it is hard to tell for sure what the underlying cause might be.

I agree that it does seem to be some sort of connectivity issue when comparing the file sizes during the attempts to install; but even after going through the options you mentioned in your previous comment, it's still failing to fetch the repo and install. I was originally on the RStudios repository and so I attempted the install again after choosing one closer to my location and disabling the secure download option, which unfortunately returned the same results.

I ended up installing Rtools and it's no longer telling me that I need Rtools but I'm still unable to install the 'stringi' package. I'm not sure what's going on with it but any help is greatly appreciated.

> install.packages("stringi")
Installing package into ‘C:/Users/s_mar/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/4.2/stringi_1.7.12.zip'
Content type 'application/zip' length 14221653 bytes (13.6 MB)
downloaded 3.5 MB

Warning in install.packages :
  downloaded length 3683527 != reported length 14221653
Warning in install.packages :
  URL 'http://cran.rstudio.com/bin/windows/contrib/4.2/stringi_1.7.12.zip': Timeout of 60 seconds was reached
Error in download.file(url, destfile, method, mode = "wb", ...) : 
  download from 'http://cran.rstudio.com/bin/windows/contrib/4.2/stringi_1.7.12.zip' failed
Warning in install.packages :
  download of package ‘stringi’ failed

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