12

I'm developing an internal R package which is going to be stored and installed from github, but it depends on another R package which is also in a private repo.

I know how to specify remote dependencies with the devtools Remotes: tag (vignette) and I know how to install private repositories using install_github(source, PAT). But how do I do both? The idea is to have a server just install the package, and also install all of the dependencies on github.

Shorpy
  • 1,549
  • 13
  • 28
  • Maybe create a private _repository_ instead of patching band-aid fixed around a perfectly working dependency mechanism? We use public and private [drat](https://github.com/eddelbuettel/drat) repositories... – Dirk Eddelbuettel Sep 21 '16 at 14:04
  • 4
    Store the pat in an environment variable `Sys.setenv(GITHUB_PAT = pat)` then devtools will automatically use it everywhere. – Jeroen Ooms Sep 21 '16 at 14:06
  • Oh, of course. So then I just specify the repository in `Remotes:` and it will install it normally. Because it will call `install_github()` which in turn calls `github_pat()` to look in the environment variable. Do you want to make this an answer so that I can approve it? – Shorpy Sep 21 '16 at 14:13
  • 1
    Update, it seems like @Jeroen's approach should work, but there seems to be a devtools bug which hasn't yet been resolved: https://github.com/hadley/devtools/issues/1262 – Shorpy Sep 21 '16 at 19:11

1 Answers1

4

Just putting @jeroen's response in answer format:

Store the PAT in an environment variable Sys.setenv(GITHUB_PAT = PAT) then devtools/remotes will automatically use it everywhere.


This works when the private repos all use the same PAT. I wonder how we'd do this for remotes with different PATs...

Daniel Egan
  • 826
  • 1
  • 9
  • 22
  • I know that this is an old thread, but just to be clear - I store the PAT in an `.Renviron` file at the root of my project. Do I add `.Renviron` to `.gitignore`, because obviously I don't want to push a PAT to a repository where it can be seen. Then I push my changes as usual and GitHub actions will use the PAT in my `.Renviron` when installing dependencies for CI and will thus download the private repository I have specified in the `Remotes:` section of my `DESCRIPTION` file? – Dylan Russell Nov 20 '20 at 20:44