FWIW, at least as far as R is concerned, you should be able to use a
file URI with a UNC path. For example, the following works for me:
repopath <- tempfile("minicran-")
dir.create(repopath)
repopath <- normalizePath(repopath, winslash = "/", mustWork =
TRUE)
miniCRAN::makeRepo("renv", path = repopath)
uncpath <- paste0("file:////localhost/c$", substring(repopath, 3L))
options(repos = c(local = uncpath))
available.packages()
install.packages("renv", type = "source")
In this example, the call to available.packages() succeeds for me. I'm
not sure if miniCRAN itself supports such URIs consistently, though. I
agree that using a mapped letter drive is the simplest workaround.
Best,
Kevin
On Thu, Apr 21, 2022 at 6:26 AM Tomas Kalibera <tomas.kalibera at
gmail.com> wrote:>
>
> On 4/6/22 18:07, mark.lee--- via R-devel wrote:
> > Hello,
> >
> > I'm responsible for maintaining a mirrored internal CRAN
repository for my organization. We have a script that uses the miniCRAN library
to add and update packages within the repository and since the repository is
stored on a network drive I have to use UNC paths when calling miniCRAN
functions such as this:
> >
> > updatePackages(path =
'\\\\my-network-drive.net\\repos\\packages', ...)
> >
> > updatePackages function in turns call pkgAvail, another miniCRAN
function, which calls available.packages and then read.dcf function. However I
discovered that this line in available.packages transforms the UNC path to a
form that read.dcf can't use:
> >
> > if (startsWith(repos, "file:///")) {tmpf <-
paste0('/', substring(repos, 8L), "/PACKAGES")
> >
> > This line transforms my UNC path to
//\\\\my-network-drive.net\\repos\\packages, which read.dcf can't use.
During debugging I found that pkgAvail transformed my UNC path to
'file:///\\\\ my-network-drive.net\\repos\\packages' and that is the
path being passed to available.packages. To fix my issue I re-defined my own
available.packages function and changed the line to:
> >
> > if (startsWith(repos, "file:///")) {tmpf <-
paste0('/', substring(repos, 10L), "/PACKAGES")
> >
> > This way the UNC path being passed to read.dcf will be
'/\\my-network-drive.net\\repos\\packages', which read.dcf can use.
I'm wondering if similar changes can be made in the available.packages
function for the next R release to automatically detect UNC paths and modify it
so that it can work with UNC paths.
>
> R does not support UNC paths, even though they work in some functions
> (as stated at least in R-intro documentation). You can use e.g. a mapped
> drive as a reliable work-around.
>
> Transforming the file URIs is tricky enough even without UNC support,
> and as UNC is only used on Windows, and there is an easy work-around,
> support for it in update.packages would have very low priority. The cost
> is not only implementing it, but also maintaining and testing. Still, to
> increase the chances, you can submit a bug (wishlist) report to R
> bugzilla, referring only to base R packages (so not e.g. miniCRAN) and
> add a well-tested patch to be considered.
>
> Best
> Tomas
>
> > Thanks,
> >
> > Mark
> >
> >
> >
> >
> >
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel