Skip to content
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

install_github with non-default host broken: "attempt to set an attribute on NULL" #396

Closed
r-cheologist opened this issue Jul 8, 2019 · 3 comments

Comments

@r-cheologist
Copy link

r-cheologist commented Jul 8, 2019

Consider the following:

requireNamespace("remotes")
remotes::install_github(
  repo = 'loosolab/MARMoSET', host = 'github.molgen.mpg.de/api/v3')

This fails with the error:

Error: Failed to install 'MARMoSET' from GitHub:
  attempt to set an attribute on NULL

This happens both with the current cran version and after invoking remotes::install_github("r-lib/remotes").

@dpprdan
Copy link
Contributor

dpprdan commented Jul 31, 2019

The error message is caused by ratelimit_reset <- .POSIXct(res_headers$x-ratelimit-reset, tz = "UTC") in github_error since this server apparently does not return a x-ratelimit-reset in its header, so res_headers$`x-ratelimit-reset = NULL`. I gather that for this server the REST API rate limit is not set. In any case, this seems to be possible according to the docs:

Note that the limits mentioned above are the default rate limits for a GitHub Enterprise Server instance. Contact your site administrator to confirm if rate limits are enabled and how they are configured.

Emphasis mine.

With my attempt to fix this applied (#413), we now get

remotes::install_github(
  repo = "loosolab/MARMoSET", host = "github.molgen.mpg.de/api/v3"
)
#> Error: Failed to install 'unknown package' from GitHub:
#>   HTTP error 401.
#>   Bad credentials

This is because install_github() uses the auth_token = github_pat() default.

Unfortunately auth_token = NULL does not help (yet).

remotes::install_github(
  repo = "loosolab/MARMoSET", host = "github.molgen.mpg.de/api/v3", 
  auth_token = NULL
)
#> Error: Failed to install 'unknown package' from GitHub:
#>   HTTP error 401.
#>   Bad credentials

This is because remote_package_name.github_remote calls github_DESCRIPTION() with pat = remote$auth_token %||% github_pat(). So since auth_token = NULL, github_DESCRIPTION() essentially tries to access the DESCRIPTION file on the github.molgen.mpg.de/api/v3 host with the PAT from the GITHUB_PAT environment variable (which is likely to be the one for github.com). Since github.molgen.mpg.de/api/v3 does not require a PAT, we get the 401 error.

Since @jimhester deliberately set %||% github_pat() in commit 203d06e, I don't know how to solve this without breaking other things at this moment.

For now, a workaround for this particular case is:

Sys.unsetenv("GITHUB_PAT")
remotes::install_github(
  repo = "loosolab/MARMoSET", host = "github.molgen.mpg.de/api/v3"
)

@reikoch
Copy link

reikoch commented Oct 3, 2019

I encountered a similar problem:
my GITHUB_PAT environment variable contained the PAT for github.com and that effectively disabled installations from our github enterprise server.

Somehow I think the PATs have to be linked to the corresponding host:

    github.com PAT1
    github.example.com PAT2
    ...

@jimhester
Copy link
Member

Fixed by #413

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants