Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning "downloaded length != reported length" in installing packages from CRAN

Searching on stackoverflow questions, I found out this link: Error in file.download when downloading custom file .

However, my case is a little bit different (I think):

1) I get this annoying warning when installing some packages from CRAN (or also just some dependencies that get generally installed together with the required package).

2) The downloaded length always appear to be equal to the reported length, so there should be no warning.
As an example, I copy-paste here the warning that has just appeared in updating mgcv.

Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
  downloaded length 1886962 != reported length 1886962

The mode argument is already set to "wb", so the solution offered in the SO link does not seem to work.

It is very strange, because I have re-installed both R and RStudio recently for other reasons, but this warning has not desappeared.

Any advise is welcome.

like image 697
Davide Passaretti Avatar asked Dec 20 '14 19:12

Davide Passaretti


3 Answers

increase the max timeout option beyond the default setting

Try: options(timeout = max(1000, getOption("timeout")))

This issue is typically caused by trying to download a large file (> 50 MB) that it exceeds the "timeout" option built-into R. The cryptic error message indicates that the amount downloaded is less than the total requested amount, because the request was killed mid-way. From the ?download.file() docs:

The timeout for many parts of the transfer can be set by the option timeout which defaults to 60 seconds. This is often insufficient for downloads of large files (50MB or more) and so should be increased when download.file is used in packages to do so. Note that the user can set the default timeout by the environment variable R_DEFAULT_INTERNET_TIMEOUT in recent versions of R, so to ensure that this is not decreased packages should use something like

options(timeout = max(300, getOption("timeout")))
like image 134
Rich Pauloo Avatar answered Nov 17 '22 13:11

Rich Pauloo


I had encountered the same problems on windows or linux server. I believed that this is probably caused by the network speed. I tried to install this package for the second or even the third time (using the function install.packages) or manually download the desired package from CRAN and then installed it and that fixed the problem.

like image 24
Ven Yao Avatar answered Nov 17 '22 13:11

Ven Yao


I solved my problem by going to this site and downloading the required package. The problem of different lengths was due to the inability to download the folder completely from R so I did download it directly and call it from the install button in Packages and selecting zip file rather than CRAN. Then just select the folder and that was for me the solution.

like image 1
David Rodriguez Avatar answered Nov 17 '22 15:11

David Rodriguez