If you find yourself getting a "Timeout of 60 seconds was reached" warning from download.file
that's preventing you from installing a package, you can increase the timeout in R by using options()
.
For example, when I was trying to run the following command:
SeuratData::InstallData('ifnb')
trying URL 'http://seurat.nygenome.org/src/contrib/ifnb.SeuratData_3.1.0.tar.gz'
Content type 'application/octet-stream' length 413266233 bytes (394.1 MB)
================
downloaded 126.6 MB
Warning in download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 132779682 != reported length 413266233
Warning in download.file(url, destfile, method, mode = "wb", ...) :
URL 'https://seurat.nygenome.org/src/contrib/ifnb.SeuratData_3.1.0.tar.gz': Timeout of 60 seconds was reached
Error in download.file(url, destfile, method, mode = "wb", ...) :
download from 'http://seurat.nygenome.org/src/contrib/ifnb.SeuratData_3.1.0.tar.gz' failed
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘ifnb.SeuratData’ failed
Error in loadNamespace(name) :
there is no package called ‘ifnb.SeuratData’
Increase the timeout by using options()
.
options(timeout = 1000)
SeuratData::InstallData('ifnb')
trying URL 'http://seurat.nygenome.org/src/contrib/ifnb.SeuratData_3.1.0.tar.gz'
Content type 'application/octet-stream' length 413266233 bytes (394.1 MB)
==================================================
downloaded 394.1 MB
* installing *source* package ‘ifnb.SeuratData’ ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (ifnb.SeuratData)
The downloaded source packages are in
‘/tmp/RtmpfhhGRo/downloaded_packages’
Some details
The options()
function:
Allow the user to set and examine a variety of global options which affect the way in which R computes and displays its results.
Documentation for the timeout option:
timeout: positive integer. The timeout for some Internet operations, in seconds. Default 60 (seconds) but can be set from environment variable R_DEFAULT_INTERNET_TIMEOUT. (Invalid values of the option or the variable are silently ignored: non-integer numeric values will be truncated.) See download.file and connections.
And finally, what is an official definition of a timeout? Here's one from Wikipedia:
A specified period of time that will be allowed to elapse in a system before a specified event is to take place, unless another specified event occurs first; in either case, the period is terminated when either event takes place. Note: A timeout condition can be canceled by the receipt of an appropriate time-out cancellation signal.
For me that's a confusing statement. I would write (but am probably wrong or inaccurate):
A specified period of time a system is allowed to idle when a specified event is requested. If the allowed idle time has passed, then the specified event is terminated.
Anyway long story short, use options(timeout = 1000)
if you find yourself downloading from a server that tends to stall. Or use a number you fancy, like 496 or 8128 seconds.
This work is licensed under a Creative Commons
Attribution 4.0 International License.