4

In our team, we are sharing self-written functions (e.g. for connecting to our dbs) via a self-written package that I set up in a git-repository (non-public).

As a general rule, we avoid to install packages in our users' accounts. Instead we use renv to get reproducible environments. How can I best handle the private package with renv? Can I somehow use renv::install() to install the package from the private git-repo with ssh-keys?

What I've done so far: I cloned the package and installed it via R CMD INSTALL path/to/folder_with_tar.gz. renv does not seem to pick up the package when running renv::init() / renv::snapshot(). I am working on using devtools to install from repository (currently waiting for IT to resolve git2r issue) but this would not solve the problem with renv.

Sorry for no MWE, I don't know how to produce one in this case.

EDIT 2022-11-08:

I want to keep this question open because this is not an answer to the question but rather a workaround. However, if using RStudio with a professional license, the best solution is to use the Package Manager. This circumvents the problem a bit: Instead of dealing with how to acces the private git from renv, the Package Manager manages the access.

evilolive
  • 407
  • 1
  • 5
  • 12
  • I don't use `renv`, but the description here: https://rstudio.github.io/renv/reference/install.html suggests you do this by setting `Remotes:` in the `DESCRIPTION` file of your private package. – user2554330 Mar 02 '22 at 10:53
  • @user2554330 : I dont' want to specify how my package should load its dependencies, I want to track my package within my renv. It was a good hint anyways as I found these options https://rstudio.github.io/renv/reference/install.html#ref-examples for installing packages from remote locations. However, I see support for github but not for azure devops, which is the repository we are using. – evilolive Mar 02 '22 at 15:41
  • Most of the `remotes::install_xxx` functions are very simple wrappers for `remotes::install_remotes`, so perhaps you can write `install_azure` using one of them as a pattern. – user2554330 Mar 02 '22 at 17:15
  • Just took a look at `renv`. It appears that if you put your package in a standard format repository, you can specify that `renv` should get it from there. (I don't know how the issue of `ssh` keys will be handled.) The `drat` package makes it really easy to set up a small repository. – user2554330 Mar 02 '22 at 17:25
  • okay, so `remotes::install_git` works when using version 2.3 (instead of current 2.4, may be related to https://github.com/r-lib/remotes/issues/621). How can I check which version of remotes is used by `renv::install('git::...')`? – evilolive Mar 03 '22 at 14:43
  • You can only have one version of a package installed at a time in each library, so if `renv::install` is using `remotes::install_git` from the default library, it will use the version of `remotes` that you have installed there. You can determine that using `packageVersion("remotes")`. (It's quite common to have two libraries: one with system permissions, one with user permissions. You can see the search order using `.libPaths()`. I wouldn't be surprised if `renv` set up others.) – user2554330 Mar 03 '22 at 17:16
  • renv does not use remotes internally; it has its own install infrastructure that is compatible with some amount of the remotes specification defined in https://cran.r-project.org/web/packages/remotes/vignettes/dependencies.html. – Kevin Ushey Mar 04 '22 at 17:20

1 Answers1

2

Renv was updated to now support Azure DevOps git repositories via ssh. There was a problem with the parsing of the URL (Git-Issue) since it is constructed a bit differently for DevOps than for other git repositories. To my knowledge, there is not yet an update for CRAN but the first renv-version to include this is commit 8f060d3.

Thanks to the developer for fixing this!

evilolive
  • 407
  • 1
  • 5
  • 12