@@ -305,6 +305,19 @@ abort <- function(msg) {
305305 quit(" no" , status = 100 )
306306}
307307
308+ get.default.cran.mirror <- function () {
309+ tryCatch({
310+ con <- file(" etc/DEFAULT_CRAN_MIRROR" , " r" );
311+ cran.mirror <<- readLines(con )[[1 ]]
312+ close(con )
313+ cran.mirror
314+ }, error = function (err ) {
315+ cat(" ERROR while getting etc/DEFAULT_CRAN_MIRROR, are you running this in FastR home directory and did you build it?" )
316+ print(err )
317+ quit(" no" , status = 1 )
318+ })
319+ }
320+
308321set.repos <- function () {
309322 # Based on the value of repos.list we set the "repos" option
310323 # which is used by available.packages etc.
@@ -328,28 +341,24 @@ set.repos <- function() {
328341 # not set on command line
329342 cran.mirror <<- Sys.getenv(" CRAN_MIRROR" , unset = " http://cloud.r-project.org/" )
330343 } else {
331- cran.mirror <- uri
344+ cran.mirror << - uri
332345 }
333346 repos [[" CRAN" ]] <- cran.mirror
334347 } else if (name == " FASTR" ) {
335348 # set the FastR internal repo
336349 repos [[" FASTR" ]] <- paste0(" file://" , normalizePath(" com.oracle.truffle.r.test.native/packages/repo" ))
337350 } else if (name == " SNAPSHOT" ) {
338- tryCatch({
339- con <- file(" etc/DEFAULT_CRAN_MIRROR" , " r" );
340- cran.mirror <<- readLines(con )[[1 ]]
341- close(con )
342- }, error = function (err ) {
343- cat(" ERROR while getting etc/DEFAULT_CRAN_MIRROR, are you running this in FastR home directory and did you build it?" )
344- print(err )
345- quit(" no" , status = 1 )
346- })
347- repos [[" CRAN" ]] <- cran.mirror
351+ repos [[" CRAN" ]] <- get.default.cran.mirror()
348352 } else {
349353 # User defined
350354 repos [[name ]] <- uri
351355 }
352356 }
357+
358+ if ((" FASTR" %in% names(repos )) && ! (" CRAN" %in% names(repos ))) {
359+ log.message(" '--repos FASTR' specified but no CRAN mirror set; setting 'CRAN=" , get.default.cran.mirror(), " '\n " , level = 1 )
360+ repos [[" CRAN" ]] <- get.default.cran.mirror()
361+ }
353362 options(repos = repos )
354363}
355364
@@ -823,7 +832,8 @@ install.pkg <- function(pkgname) {
823832
824833 # save and restore working dir in case the installation process doesn't
825834 prev.wd <- getwd()
826- rc <- pkg.cache.internal.install(pkg.cache , pkgname , contrib.url(getOption(" repos" ), " source" )[[1 ]], lib.install )
835+
836+ rc <- pkg.cache.internal.install(pkg.cache , pkgname , contrib.url(getOption(" repos" ), " source" ), lib.install )
827837 setwd(prev.wd )
828838
829839 success <- FALSE
0 commit comments