@@ -305,6 +305,19 @@ abort <- function(msg) {
305
305
quit(" no" , status = 100 )
306
306
}
307
307
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
+
308
321
set.repos <- function () {
309
322
# Based on the value of repos.list we set the "repos" option
310
323
# which is used by available.packages etc.
@@ -328,28 +341,24 @@ set.repos <- function() {
328
341
# not set on command line
329
342
cran.mirror <<- Sys.getenv(" CRAN_MIRROR" , unset = " http://cloud.r-project.org/" )
330
343
} else {
331
- cran.mirror <- uri
344
+ cran.mirror << - uri
332
345
}
333
346
repos [[" CRAN" ]] <- cran.mirror
334
347
} else if (name == " FASTR" ) {
335
348
# set the FastR internal repo
336
349
repos [[" FASTR" ]] <- paste0(" file://" , normalizePath(" com.oracle.truffle.r.test.native/packages/repo" ))
337
350
} 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()
348
352
} else {
349
353
# User defined
350
354
repos [[name ]] <- uri
351
355
}
352
356
}
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
+ }
353
362
options(repos = repos )
354
363
}
355
364
@@ -823,7 +832,8 @@ install.pkg <- function(pkgname) {
823
832
824
833
# save and restore working dir in case the installation process doesn't
825
834
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 )
827
837
setwd(prev.wd )
828
838
829
839
success <- FALSE
0 commit comments