usethis::use_release_issue() GitHub API error 404

I created a package, corrarray, and used usethis::use_github(protocol = "https", authtoken = GITHUB_PAT) and was able to create a github repository. Then, to prepare the package for CRAN submission, I used usethis::use_release_isssue() but got the following error:

> use_release_issue()
Current version is 0.1.0.
Which part to increment? (0 to exit) 

1: major --> 1.0.0
2: minor --> 0.2.0
3: patch --> 0.1.1
4:   dev --> 0.1.0.9000

Selection: 1
Error in gh_process_response(raw) : 
GitHub API error (404): 404 Not Found
Message: Not Found
Read more at https://developer.github.com/v3/issues/#create-an-issue

URL not found: https://api.github.com/repos/Medicine1/corrarray/issues

I seem to be authenticated, and it seems that R can access the URLs:

res <- httr::GET("https://api.github.com/repos/Medicine1/corrarray")
> httr::status_code(res)
[1] 200
> res <- httr::GET("https://api.github.com/repos/Medicine1/corrarray/issues")
> httr::status_code(res)
[1] 200

I am not sure why the URL is not found. This is my first package, so I am relatively new to package development. I would appreciate your help with this!

System information:

  • RStudio Version: 1.3.1056

  • R Version: 4.0.2

  • OS Version: OS X 10.15.4

1 Like

That is strange. If you were able to create a repository using your GitHub PAT, you should be able to create an Issue. The scope "repo" or even only "public_repo" should be sufficient to create an Issue.

Did you change the PAT you are using? You can confirm your scopes with gh::gh_whoami().

How did you create the 2 issues on the repository? Did you do this manually on GitHub?

1 Like

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()
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.