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

source_gist "Error: client error: (404) not found error" #348

Closed
sfuj opened this Issue Sep 17, 2013 · 5 comments

Comments

Projects
None yet
3 participants
@sfuj

sfuj commented Sep 17, 2013

I'm not sure if it is just my system, but source_gist doesn't seem to work anymore.. I've tried my own gists and the ones in ?source_gist

My first bug report, so apologies if this isn't the way to do it.

I get the same error on both devtools version 1.2 and 1.3.99 (both on R 2.15.2)

source_gist('https://gist.github.com/sfuj/6605249')
[1] "https://raw.github.com/gist/6605249"
Error: client error: (404) Not Found

@jeffwong

This comment has been minimized.

jeffwong commented Sep 18, 2013

I saw this too. the source_gist command uses source_url underneath, which uses Rcurl to retrieve the file; if you enter https://raw.github.com/gist/1654919 into your web browser you'll find that it truly doesn't exist. I think github must have changed the way it structures its urls, and devtools just hasn't caught up

Here is a link on SO describing how gist urls have changed
http://stackoverflow.com/questions/12522539/github-gist-editing-without-changing-url

@hadley

This comment has been minimized.

Member

hadley commented Sep 18, 2013

@sfuj It'd be useful if you could post the correct url

@jeffwong

This comment has been minimized.

jeffwong commented Sep 18, 2013

Here's a quick fix that should do the trick - note that username has to be passed in now. It would be cool if there was some kind of regex to extract the username from a url if the user specified something like

https://gist.github.com/jeffwong/6517317

source_gist <- function(entry, username, ..., sha1 = NULL) {
  # 1654919 or "1654919"
  if (is.numeric(entry) ||  grepl("^[0-9a-f]+$", entry)) {
    entry <- sprintf("https://gist.github.com/%s/%s/raw", username, entry)
  }
  # https://gist.github.com/kohske/1654919, https://gist.github.com/1654919,
  # or gist.github.com/1654919
  else if (grepl("((^https://)|^)gist.github.com/([^/]+/)?[0-9a-f]+$", entry)) {
    entry <- sprintf("https://gist.github.com/%s/%s/raw",
                     username,
                     regmatches(entry, regexpr("[0-9a-f]+$", entry)))
  }
  print(entry)
  source_url(entry, ..., sha1 = sha1)
}
@sfuj

This comment has been minimized.

sfuj commented Sep 18, 2013

apologies @hadley, although those urls were from ?source_gist, I should've tried them before posting.

Just created a dummy public gist.. if that helps.

@hadley

This comment has been minimized.

Member

hadley commented Sep 27, 2013

To fix this properly, we should probably use the github api to look up the correct url from the id. This would prevent it from breaking in the future if github changes formats again.

@hadley hadley closed this in 127ec4d Oct 7, 2013

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

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