Usethis: Mention remotes in GitHub creds vignette?

Created on 24 Mar 2021  路  4Comments  路  Source: r-lib/usethis

One issue that I've had in sending people to the GH creds vignette is that remotes doesn't yet support the git cred store approach used by gert and gh (https://github.com/r-lib/remotes/issues/587), a problem which we bump into quickly since we use private GH repos on our team.

Hopefully, this will be a non-issue soon, but is it worth mentioning (temporarily?) in the vignette that remotes doesn't yet support this approach?

All 4 comments

Related to #1413 (where the coffee table the user banged their shins on was exactly remotes::install_github()).

I just banged my shins on this one, as well! I was setting up a new installation, and couldn't figure out why remotes::install_github() couldn't see my org's private repos, despite everything looking right in usethis::git_sitrep(). Adding the GITHUB_PAT in .Renviron took care of it.

I'd rather not go back to encouraging storage in .Renviron. I think a better temporary workaround (for example, until remotes gains this feature or something else saves us) is to tickle gitcreds in .Rprofile, i.e. to cause your PAT to be eagerly retrieved from the store and made available as GITHUB_PAT in the current R session. This is still suboptimal, because it causes GITHUB_PAT to be set in all sessions, whether it's needed or not. But it's still safer than putting the PAT in .Renviron.

BTW 馃憜 is about local, interactive(-ish) use. I'm not talking about CI, where we regularly set the GITHUB_PAT env var.

What I mean by "tickle gitcreds" is basically this (although this tweet uses the credentials package), but I can't quite bring myself to officially recommend it:

https://twitter.com/dataandme/status/1328372767444623360

So, a call to credentials::set_github_pat() or gitcreds::gitcreds_get(), suitably wrapped w/ some attention to interactivity, messaging, and possible failure.

I ran into this also, and I agree that it'd be nice to alert users to this in the vignette (until https://github.com/r-lib/remotes/issues/587 is resolved or we otherwise reach github auth nirvana).

I've also noticed that gitcreds::gitcreds_set() and credentials::set_github_pat() don't (always) play nice together: https://github.com/r-lib/credentials/issues/16.

I've thus decided to * *only rely on gitcreds** and amend my .Rprofile thus:

# required b/c remotes can't access Git credential managers https://github.com/r-lib/remotes/issues/516
Sys.setenv(GITHUB_PAT = gitcreds::gitcreds_get(use_cache = FALSE)$password)

This fixes remotes.
Happily, gert also works with this, even though it depends on the rival (?)

Still missing:

suitably wrapped w/ some attention to interactivity, messaging, and possible failure

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EmilHvitfeldt picture EmilHvitfeldt  路  3Comments

pieterjanvc picture pieterjanvc  路  5Comments

jennybc picture jennybc  路  4Comments

Jadamso picture Jadamso  路  3Comments

aosmith16 picture aosmith16  路  5Comments