diff --git a/src/cpp/session/modules/ModuleTools.R b/src/cpp/session/modules/ModuleTools.R index 6090e073089..a6b2dccab1e 100644 --- a/src/cpp/session/modules/ModuleTools.R +++ b/src/cpp/session/modules/ModuleTools.R @@ -1,7 +1,7 @@ # # ModuleTools.R # -# Copyright (C) 2009-15 by RStudio, Inc. +# Copyright (C) 2009-17 by RStudio, Inc. # # Unless you have received this program directly from RStudio pursuant # to the terms of a commercial license agreement with RStudio, then @@ -121,19 +121,17 @@ # the repos option is canonically a named character vector, but could also # be a named list if (is.character(repos) || is.list(repos)) { - if (is.null(names(repos))) { - # no indication of which repo is which, presume the first entry to be - # CRAN if it's of character type - if (length(repos) > 0 && is.character(repos[[1]])) - repo <- repos[[1]] - } else { - # use repo named CRAN - repo <- as.character(repos["CRAN"]) + # check for a repo named "CRAN" + repo <- as.character(repos["CRAN"]) + + # if no repo named "CRAN", blindly guess that the first repo is a CRAN mirror + if (length(repo) < 1 || is.na(repo)) { + repo <- as.character(repos[[1]]) } } # if no default repo and no repo marked CRAN, give up - if (is.na(repo)) { + if (length(repo) < 1 || is.na(repo)) { return(list(version = "", satisfied = FALSE)) }