Skip to content

Error using install_github(): HTTP error 401. Bad credentials. #641

Closed
@isaactpetersen

Description

@isaactpetersen

I'm trying to install an R package from a publicly available GitHub repo using install_github() from the {remotes} package. I'm doing this in the context of a Docker image (rocker/verse) using a GitLab runner that that will output a book to GitLab Pages using {bookdown}. However, I receive an error when trying to install an R package ({uroc}) from a publicly available GitHub repo (https://github.com/evwalz/uroc).

Here is a minimal reproducible example based on my .gitlab-ci.yml file:

variables:
  GIT_STRATEGY: clone

image: rocker/verse

.bookdown:
  stage: deploy
  script:
    - R -e "install.packages('remotes')"
    - R -e "remotes::install_github('evwalz/uroc')"

Here is the error I receive:

> remotes::install_github('evwalz/uroc')
Using bundled GitHub PAT. Please add your own PAT to the env var `GITHUB_PAT`
Error: Failed to install 'unknown package' from GitHub:
  HTTP error 401.
  Bad credentials
  Rate limit remaining: 52/60
  Rate limit reset at: 2021-08-15 17:58:54 UTC

Interestingly, I can install it fine when running the code locally, and when I run the Docker container locally, the package installs fine, as well. So it appears to be some interaction of the Docker container with the GitLab runner.

The issue appears to be similar to other issues:
#638
#481
#330
r-lib/devtools#1676
Azure/doAzureParallel#359
https://gist.github.com/Z3tt/3dab3535007acf108391649766409421

For instance, in Issue #638, the user was able to fix the HTTP error 401 on GitHub Actions by defining GITHUB_PAT with the job's token:

    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

The user in the other thread noted that it seems that relying on the bundled PAT is not robust. However, I'm not sure how to do that in the context of a GitLab runner (not GitHub Actions) in my .gitlab-ci.yml file. Also, please note that I'm trying to download an R package from a publicly available GitHub repo, so it shouldn't require at Personal Access Token (PAT).

Here's my sessionInfo():

> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS
Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C             
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
other attached packages:
[1] remotes_2.4.0
loaded via a namespace (and not attached):
[1] compiler_4.1.1 tools_4.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions