Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
use_github does not push with https protocol and GITHUB_PAT #320
I tried to create a
First my setup is:
Howerver, when using https protocol,
Here how to reproduce the issue
testdir <- tempfile("testdir") dir.create(testdir) setwd(testdir) library(usethis) #> Warning: le package 'usethis' a été compilé avec la version R 3.4.4 create_package("testpkg", open = FALSE) #> Changing active project to testpkg #> <U+2714> Creating 'R/' #> <U+2714> Creating 'man/' #> <U+2714> Writing 'DESCRIPTION' #> <U+2714> Writing 'NAMESPACE' setwd(file.path(testdir, "testpkg/")) use_git() #> <U+2714> Initialising Git repo #> <U+2714> Adding '.Rhistory', '.RData', '.Rproj.user' to './.gitignore' #> <U+2714> Adding files and committing use_github(protocol = "https") #> <U+2714> Setting title and description #> Name: testpkg #> Description: What the Package Does (One Line, Title Case) #> <U+2714> Creating GitHub repository #> <U+2714> Adding GitHub remote #> <U+2714> Adding GitHub links to DESCRIPTION #> <U+2714> Setting URL field in DESCRIPTION to 'https://github.com/cderv/testpkg' #> <U+2714> Setting BugReports field in DESCRIPTION to 'https://github.com/cderv/testpkg/issues' #> <U+2714> Pushing to GitHub and setting remote tracking branch #> Error in (function (classes, fdef, mtable) : unable to find an inherited method for function 'cred_user_pass' for signature '"character", "NULL"'
the last step failed. The repository was created but use_github was not able to push to the repository. It seems it can’t deal with current git2r credential.
The credentials used are built with
As it seems strange to me I tried another way.
r <- git2r::repository(file.path(testdir, "testpkg/")) cred <- git2r::cred_token() git2r::push(r, "origin", "refs/heads/master", credentials = cred)
There is also a way to use user/pass auth with the token using the username (or organization) and token as password.
cred2 <- git2r::cred_user_pass("cderv", Sys.getenv("GITHUB_PAT")) # nothing to push but no error git2r::push(r, "origin", "refs/heads/master", credentials = cred) # cleaning this reprex unlink(testdir, recursive = TRUE) # delete manually the repo on github
A the end, do you think the choice in
I am wiling to help with a PR when ready. Thanks.
When this function was initially created, back inside devtools, the
Then here, its default was changed to
But I don't see any arrangement made to fetch the GitHub PAT for git2r's use. gh will retrieve it automatically, yes, but that isn't going to help us in
A PR to fix this would be welcome @cderv.
This is how people with 2FA turned on can still interact with GitHub over https. This is a deliberate choice. I push this way at this point because I know I have a PAT, since we needed to create a repo.
Thanks for the clarification. I better understand the choices and what is going on.
I understand the
I see two solutions using GITHUB_PAT :
I will PR something based on the second one, unless we could consider relying only on environment variable and you find the first one better.
I'll do that quickly, don't worry.
@batpigandme Yes this is a bit different. I mange to push when using https and the correct way to pass credential. Here, this is just a small issue of checking
We obviously never circled back to this, even though git2r is now well past v0.11.0!
In theory, we could use
I have already brought a copy of
Here's the reference for what we're doing with the PAT and HTTPS:
If you make a PR, please include any manual tests you run. That would be a great start on #322, even if you don't finish it off, i.e. even if you just look at HTTPS scenarios.
OK I see what to do. Thanks.
I'll do that this week.