Devtools::install_github() error: This endpoint requires you to be authenticated. (401)

On Ubuntu 14.04.1 and R-3.4.4, I am suddenly getting this error, when trying to install tidyverse via devtools

> devtools::install_github('hadley/tidyverse')
Error in stop(github_error(req)) : 
  This endpoint requires you to be authenticated. (401)

I have installed tidyverse multiple times, but never had this error - Any suggestions to what is going wrong?

1 Like

What's the traceback? It looks like you need to be signed into github? Also, just an FYI (it'll work the same), but the updated install location is 'tidyverse/tidyverse'.

Here is the traceback with the updated install location:

> devtools::install_github("tidyverse/tidyverse")
Error in stop(github_error(req)) : 
  This endpoint requires you to be authenticated. (401)
> traceback()
10: stop(github_error(req))
9: github_response(req)
8: github_POST("graphql", body = jsonlite::toJSON(auto_unbox = TRUE, 
       list(query = query, variables = list(org = username, repo = repo, 
           ref = ref))))
7: github_sha(username = remote$username, repo = remote$repo, host = remote$host, 
       ref = remote$ref, pat = remote$auth_token)
6: remote_sha.github_remote(remote)
5: remote_sha(remote)
4: FUN(X[[i]], ...)
3: vapply(remotes, install_remote, ..., FUN.VALUE = logical(1))
2: install_remotes(remotes, quiet = quiet, ...)
1: devtools::install_github("tidyverse/tidyverse")

Hmm, yeah, it looks like you need to be authenticated with GitHub (true confession: I could be wrong). Do you have this problem installing from GH with devtools on other packages?

Same issue with e.g. devtools:

> devtools::install_github("r-lib/devtools")
Error in stop(github_error(req)) : 
  This endpoint requires you to be authenticated. (401)
> traceback()
10: stop(github_error(req))
9: github_response(req)
8: github_POST("graphql", body = jsonlite::toJSON(auto_unbox = TRUE, 
       list(query = query, variables = list(org = username, repo = repo, 
           ref = ref))))
7: github_sha(username = remote$username, repo = remote$repo, host = remote$host, 
       ref = remote$ref, pat = remote$auth_token)
6: remote_sha.github_remote(remote)
5: remote_sha(remote)
4: FUN(X[[i]], ...)
3: vapply(remotes, install_remote, ..., FUN.VALUE = logical(1))
2: install_remotes(remotes, quiet = quiet, ...)
1: devtools::install_github("r-lib/devtools")

It's weird, 'cause I have previously installed on this server with no issues...

Weird.
Just to clarify, then, the issue is with devtools/remotes, and not the tidyverse package (which I say, not because you're trying to install devtools, rather, because you're using the function from devtools :wink:).

aside

I'm guessing you know this, I'm just being explicit for anyone who comes along in the future and sees this thread thinking they might have the same issue.

Right you are @mara, I have corrected the question title :slightly_smiling_face:

The problem persists...

1 Like

I've got nothing concrete here, but thought I'd throw out some ideas.

  1. that seems like it's a github error. I just tested and had no trouble installing either of the things you tried.
  2. do you have any trouble connecting to github via a browser?
  3. possible that you're behind a firewall that has started molesting connections in some new way?

I can't really figure out was going on. I tried from my MBP, which I have on the University wifi and that's all good. When I SSH into the ubuntu server, which is on cabled internet, the problem arises. However, it is a new problem, I'll investigate further tomorrow...

Can you check the version of devtools you are using?
It seems to me from traceback that it is using the new github gaphql API for which support has been added in dev version of devtools. It aims at better support for github enterprise and private repo. :thinking:There may be an issue there... Or you need to stay really up to date with dev version as it already could have been updated.

Can you try with CRAN devtools? And can you check on your different tested environment if it is the same version of devtools? Thanks!

Yup:

> packageVersion("devtools")
[1] ‘1.13.6.9000’
> install.packages("devtools")
trying URL 'https://mirrors.dotsrc.org/cran/src/contrib/devtools_1.13.6.tar.gz'
Content type 'application/octet-stream' length 486446 bytes (475 KB)
==================================================
downloaded 475 KB

* installing *source* package ‘devtools’ ...
** package ‘devtools’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (devtools)

The downloaded source packages are in
	‘/tmp/RtmpLGg9JP/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
> library("devtools")
> packageVersion("devtools")
[1] ‘1.13.6’
> install_github("tidyverse/tidyverse")

Now it works again? Apparently something is different between GitHub devtools 1.13.6.9000 and CRAN devtools 1.13.6

For now it seems, I am good to go from my cabled Ubuntu server...

Fun fact: On my MBP, which connects via wifi, I am running devtools 1.13.6.9000, with no problems :face_with_monocle:

Surely, x.x.x.9000 means dev version, but dev version can change pretty quickly and you need to focus on the commit sha to compare what can be different. Depending when you installed the dev version, the 1.13.6.9000 could be different versions on your both computer.

Current dev version of devtools adds support for graphql github API, so yes this is something different from CRAN version in the dev version. If you have two dev version, either the latest works and it means a bug has been fixed or the lastest does not work and a bug has been introduce.

You can use devtools::session_info to compare versions. The commit of your dev version will be indicated.

I hope it is clearer.

That's the goal! You can see the changes made since the last release in NEWS.md (this is true for almost all of the tidyverse packages, and many r-lib ones as well):

  • remote_sha.github() now uses the graphql API, so works better with GitHub
    enterprise and private repositories. (#1827, @renozao).

If you think there's a bug introduced by this change (above), and there's no existing issue in the repo, you could definitely open one.

1 Like

Filed the issue at https://github.com/r-lib/devtools/issues/1844

The current workaround is to generate a personal access token and set it as GITHUB_PAT environment variable

4 Likes

Thank you for putting in the time to do this!