Hi,
is it intended that one cannot install packages in non-interactive mode,
without explicitly setting a CRAN mirror (see below)?
Couldn't a default mirror be used in that case?
Thank you.
Bests,
Renaud
$ Rscript --vanilla -e "install.packages('whatever')"
Installing package into '/home/renaud/R/x86_64-pc-linux-gnu-library/3.0'
(as 'lib' is unspecified)
Error in contrib.url(repos, type) :
trying to use CRAN without setting a mirror
Calls: install.packages -> grep -> contrib.url
Execution halted
[[alternative HTML version deleted]]
On 14/02/2014 10:03, Renaud Gaujoux wrote:> Hi, > > is it intended that one cannot install packages in non-interactive mode, > without explicitly setting a CRAN mirror (see below)? > Couldn't a default mirror be used in that case? > Thank you.You seem to be talking about installing from CRAN. The intention is indeed that in non-interactive use you have to select the repositories you want to use. See ?setRepositories and its links. It is up to you to set a default mirror: we have little idea where you live (and it may not be where your email address suggests). Geolocation of mirrors had been mooted but not implemented (and in a corporate setting is not 100% reliable). The whole point of mirrors is to spread the load: without them there would be no CRAN as the main host would not allow the traffic. This would have been appropriate for R-help, if it would not have been answered by doing the homework required by the posting guide (which also requires no HTML ...).> > Bests, > Renaud > > $ Rscript --vanilla -e "install.packages('whatever')" > Installing package into '/home/renaud/R/x86_64-pc-linux-gnu-library/3.0' > (as 'lib' is unspecified) > Error in contrib.url(repos, type) : > trying to use CRAN without setting a mirror > Calls: install.packages -> grep -> contrib.url > Execution halted > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Renaud,
The script below has been in use for about as long as littler existed, and
also ships with it. I use it, and its sibbling 'update.r' all the time.
Doing
this at the command-line frees the R prompt during compilations too...
As Barry suggests, the RStudio-provided CDN is not a bad choice either as a
repo.
Dirk
edd at max:~$ cat bin/install.r
#!/usr/bin/env r
#
# a simple example to install one or more packages
if (is.null(argv) | length(argv)<1) {
cat("Usage: installr.r pkg1 [pkg2 pkg3 ...]\n")
q()
}
## adjust as necessary, see help('download.packages')
#repos <- "http://cran.us.r-project.org"
repos <- "http://cran.r-project.org"
## this makes sense on Debian where no packages touch /usr/local
lib.loc <- "/usr/local/lib/R/site-library"
install.packages(argv, lib.loc, repos)
edd at max:~$
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
Possibly Parallel Threads
- url, readLines, source behind a proxy
- Call function only when running via R CMD check?
- How to do package cleanup: hooks .onUnload, R_unload_mylib, .onDetach are not called on quit
- install.packages deletes PACKAGES file in local repo
- Specify CRAN repository from command line