New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cryptic error from install_github() if reference doesn't exist #1204

Closed
jennybc opened this Issue Jun 3, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@jennybc
Member

jennybc commented Jun 3, 2016

If you try to install from github ref that doesn't exist, the error message can be pretty odd. Here's an attempt to install from a PR that has been closed and the underlying branch deleted.

devtools::install_github("rstudio/rmarkdown#711")
#> Using GitHub PAT from envvar GITHUB_PAT
#> Using GitHub PAT from envvar GITHUB_PAT
#> Downloading GitHub repo rstudio/rmarkdown@feature/html-vignette-readme
#> from URL https://api.github.com/repos/rstudio/rmarkdown/zipball/feature/html-vignette-readme
#> No encoding supplied: defaulting to UTF-8.
#> Error: lexical error: invalid char in json text.
#>                                        Not Found
#>                      (right here) ------^

I get same message for a tag or SHA or branch that never existed, i.e., devtools::install_github("rstudio/rmarkdown@v5") or devtools::install_github("rstudio/rmarkdown@1234567") of devtools::install_github("rstudio/rmarkdown@nope").

But the error for a PR that never existed is different and is more informative.

devtools::install_github("rstudio/rmarkdown#20000")
#> Using GitHub PAT from envvar GITHUB_PAT
#> condition in stop(github_error(req)): Not Found (404)
#> *
@jimhester

This comment has been minimized.

Member

jimhester commented Jun 6, 2016

GitHub returns a regular HTTP response in the first case, whereas in the second it returns a JSON response. Devtools is always expecting a JSON response, which is why you got the confusing error.

#1211 tries to parse the response as JSON, if it fails it treats the response content as a message which cleans up this issue.

download_github(tempfile(), "https://api.github.com/repos/rstudio/rmarkdown/zipball/feature/html-vignette-readme")
#> Error in stop(github_error(request)) : Not Found (404)
@lock

This comment has been minimized.

lock bot commented Sep 18, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Sep 18, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.