Thank you very much for pointing that out. The issue has now been resolved.
Yes, I changed the PAT and "stored" it in the R environment (without .Renviron). However, gh::gh_whoami()
returned an error saying no PAT was available. I did manually create the two issues on GitHub.
Basically, I had been storing the PAT using the Console instead of using .Renviron. use_github(protocol = "https", authtoken = "012abc")
worked because I gave the token as an argument. use_release_issue()
does not accept an authtoken
argument, to my knowledge.
For readers new to package development, here is the workflow I used to successfully create and store a PAT to proceed with functions such as use_release_issue()
:
# Step 1: Check whether a PAT is in use.
> library(usethis)
> gh::gh_whoami()
No personal access token (PAT) available.
Obtain a PAT from here:
https://github.com/settings/tokens
For more on what to do with the PAT, see ?gh_whoami.
# Step 2: As no PAT is available, generate a new token in GitHub Settings under NOTE: R:GITHUB_PAT. If NOTE is already in use and previous token was not stored, Then click 'Personal Access Tokens' > 'Generate New Token'.
> browse_github_pat()
✓ Opening URL 'https://github.com/settings/tokens/new?scopes=repo,gist,user:email&description=R:GITHUB_PAT'
● Call `usethis::edit_r_environ()` to open '.Renviron'.
● Store your PAT (personal access token) with a line like:
GITHUB_PAT=xxxyyyzzz
[Copied to clipboard]
● Make sure '.Renviron' ends with a newline!
# Step 3: Store PAT. (PAT shown below is shortened from true 40-character PAT). [this code does not store the PAT properly]
> GITHUB_PAT = "012abc"
> gh::gh_whoami()
No personal access token (PAT) available.
Obtain a PAT from here:
https://github.com/settings/tokens
For more on what to do with the PAT, see ?gh_whoami.
# Step 3 corrected: Store PAT using .Renviron.
> edit_r_environ()
● Modify '/Users/[name]/.Renviron'
● Restart R for changes to take effect
# Step 4: In the new .Renviron file that opens in RStudio, enter the PAT without using quotes. Then, enter a line break at the end.
GITHUB_PAT=012abc
# Step 5: Restart R, such as via Session > Restart R or .rs.restartR().
# Step 6: Confirm that token is now available.
> gh::gh_whoami()
{
"name": {},
"login": "Medicine1",
"html_url": "https://github.com/Medicine1",
"scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user:email, workflow, write:discussion, write:packages",
"token": "01..."
}
# Now, issues can be created on GitHub straight from RStudio.
> use_release_issue()