When I set multiple repositories in options(repos=...) the order of access
is providing me with some surprises as I work through some CICD issues:

Given:

options(
   repos = c(
     CRAN = "http://localhost:3001/proxy";,
     C = "http://172.17.0.1:3002";,
     B = "http://172.17.0.1:3001/proxy";,
     A = "http://localhost:3002";
   )
)


the order in the build log after this is :

#12 178.7 Warning: unable to access index for repository
http://localhost:3001/proxy/src/contrib:
#12 178.7   cannot open URL '
http://localhost:3001/proxy/src/contrib/PACKAGES'
#12 178.7 Warning: unable to access index for repository
http://172.17.0.1:3002/src/contrib:
#12 178.7   cannot open URL 'http://172.17.0.1:3002/src/contrib/PACKAGES'
#12 178.9 Warning: unable to access index for repository
http://localhost:3002/src/contrib:
#12 178.9   cannot open URL 'http://localhost:3002/src/contrib/PACKAGES'
#12 179.0 trying URL '
http://172.17.0.1:3001/proxy/src/contrib/png_0.1-8.tar.gz'
#12 179.1 Content type 'application/x-gzip' length 24880 bytes (24 KB)


Which indicates that the order is:

CRAN, C, A, B...

note that A comes before B in the URL accesses when I was expecting either
CRAN, C, B, A if its is physical order, or alphabetically would be A, B, C,
CRAN.

As an alternative, given:

options(
repos = c(
C = "http://172.17.0.1:3002";,
B = "http://172.17.0.1:3001/proxy";,
A = "http://localhost:3002";,
CRAN = "http://localhost:3001/proxy";
)
)


The order is:

#12 0.485 Warning: unable to access index for repository
http://172.17.0.1:3002/src/contrib:
#12 0.485   cannot open URL 'http://172.17.0.1:3002/src/contrib/PACKAGES'
#12 1.153 Warning: unable to access index for repository
http://localhost:3002/src/contrib:
#12 1.153   cannot open URL 'http://localhost:3002/src/contrib/PACKAGES'
#12 1.153 Warning: unable to access index for repository
http://localhost:3001/proxy/src/contrib:
#12 1.153   cannot open URL '
http://localhost:3001/proxy/src/contrib/PACKAGES'
#12 1.250 trying URL '
http://172.17.0.1:3001/proxy/src/contrib/rlang_1.1.3.tar.gz'


Which seems to be C, A, CRAN, B.

What is it about B?

The help doesn't talk about this.  It says:

repos:
character vector of repository URLs for use by available.packages and
related functions. Initially set from entries marked as default in the
‘repositories’ file, whose path is configurable via environment variable
R_REPOSITORIES (set this to NULL to skip initialization at startup). The
‘factory-fresh’ setting from the file in R.home("etc") is c(CRAN="@CRAN@"),
a value that causes some utilities to prompt for a CRAN mirror. To avoid
this do set the CRAN mirror, by something like


local({
    r <- getOption("repos")
    r["CRAN"] <- "https://my.local.cran";
    options(repos = r)
})
in your ‘.Rprofile’, or use a personal ‘repositories’ file.


Note that you can add more repositories (Bioconductor, R-Forge, RForge.net,
...) for the current session using setRepositories.


Now I am not setting the values in exactly the way that the manual says, so
I experimented in case something was wrong there:

 options('repos')$repos
                         CRAN
"https://cloud.r-project.org";
> local({+     r <- getOption("repos")+     r["CRAN"] <- 
> "https://my.local.cran"+     options(repos = r)+ })> options('repos')$repos
                   CRAN
"https://my.local.cran";
> str(options('repos'))List of 1
 $ repos: Named chr "https://my.local.cran";
  ..- attr(*, "names")= chr "CRAN"> local({+     r <-
getOption("repos")+     r["CRAN"] <- "https://my.local.cran"+
options(repos = r)+ })> options(+     repos = c(+         C =
"http://172.17.0.1:3002",+         B =
"http://172.17.0.1:3001/proxy",+         A = "http://localhost:3002",+
        CRAN = "http://localhost:3001/proxy"+     )+ )>
options('repos')$repos
                             C                              B
                    A                           CRAN
      "http://172.17.0.1:3002"; "http://172.17.0.1:3001/proxy";
"http://localhost:3002";  "http://localhost:3001/proxy";
> str(options('repos'))List of 1
 $ repos: Named chr [1:4] "http://172.17.0.1:3002";
"http://172.17.0.1:3001/proxy"; "http://localhost:3002";
"http://localhost:3001/proxy";
  ..- attr(*, "names")= chr [1:4] "C" "B" "A" "CRAN"> local({+     r
<- getOption("repos")+     r["CRAN"] <- "https://my.local.cran"+
r["C"] = "http://172.17.0.1:3002"+     r["B"] =
"http://172.17.0.1:3001/proxy"+     r["A"] = "http://localhost:3002"+
   r["CRAN"] = "http://localhost:3001/proxy"+     options(repos = r)+
})> > str(options('repos'))List of 1
 $ repos: Named chr [1:4] "http://172.17.0.1:3002";
"http://172.17.0.1:3001/proxy"; "http://localhost:3002";
"http://localhost:3001/proxy";
  ..- attr(*, "names")= chr [1:4] "C" "B" "A" "CRAN"> options('repos')$repos
                             C                              B
                    A                           CRAN
      "http://172.17.0.1:3002"; "http://172.17.0.1:3001/proxy";
"http://localhost:3002";  "http://localhost:3001/proxy";


So I don't think I am doing anything obviously accidentally weird there.
The RStudio documentation talks about this issue directly, but I'm
scripting R not RStudio and the behaviour appears to be different anyway.

What is the expected behaviour when there are multiple repositories?  Is
there a deterministic ordering?  Do the names have an effect?


Greg

        [[alternative HTML version deleted]]

______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to