I accidentally changed my PAT while demonstrating how gitcreds::gitcreds_set() works. I then decided the best plan was to regenerate a new PAT. However, upon trying to work through the process of having my PAT recognized, I've come across some major issues.
When I run gitcreds::gitcreds_set(), I select option 2, replacing the current credentials for https://github.com. I see the following output:
-> Removing current credentials...
? Enter new password or token: NEW_PAT_ENTERED
-> Adding new credentials...
-> Removing credetials from cache...
-> Done.
However, when I then run gh::gh_whoami(), I get the following output:
gh::gh_whoami()
#> Error in validate_gh_pat(new_gh_pat(x)): A GitHub PAT must consist of 40 hexadecimal digits
Created on 2021-05-18 by the reprex package (v2.0.0)
Have you tried updating gh? See this thread for some suggestions on this error: https://twitter.com/JennyBryan/status/1394824309554630656
@malcolmbarrett -- This completely fixed it! You are a life saver!
For anyone else who stumbles here:
@jennybc -- I love the Git Credentials set-up you linked! In fact I reference it every time I teach version control. That being said, after spending hours pouring over this and the documentation for the credentials and gitcreds packages, I'm a bit disappointed that there was no indication that I needed to update gh.
Could a sentence be added to the Put your PAT into the Git credential store section, suggesting how to troubleshoot this issue? I'm happy to put in a PR for this change, especially since I can use the pr_XXX() functions again!
Sure a PR is welcome. By way of explanation, GitHub announced that change in early March and implemented it less than a month later. So we hustled to re-release gh. And all of that happened well after that article was first written.
Sorry to glom onto a closed issue (I had this problem today), but would it be worth updating the minimum version of gh to 1.2.1, as a way to avoid the behavior?
Currently:
https://github.com/r-lib/usethis/blob/486ed15e93c0d2421a623249441aa0685a124733/DESCRIPTION#L40
@ijlyttle Sure that is a good idea. Not sure how soon usethis will have a release, but that's neither here nor there.
Most helpful comment
For anyone else who stumbles here: