-
Notifications
You must be signed in to change notification settings - Fork 62
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
Support GITLAB_PAT #588
Comments
This is already possible, see the gitcreds package for the env var you need to define for your host. E.g. for gitlab.org:
So We should document this better. |
Thanks for the fast response. Would you be interested in a docs-only PR to mention this? |
Does it actually work? :D |
It does :-) |
Yeah, in that case a PR is welcome. I'll probably also add a function to pak to call gitcreds internally. We should probably also support |
The |
No, I can do that later, or I can add it to the PR. gitcreds is already included in pak: https://github.com/r-lib/pak/blob/main/src/library/pkgdepends/R/git-auth.R |
Dear @gaborcsardi The method describe here to install packages from private gitlab.com/org repositories does not seem to work for private gitlab instances. See reprex anonymized below gitcreds::gitcreds_cache_envvar("https://boulangerie.thinkr.fr")
#> [1] "GITHUB_PAT_BOULANGERIE_THINKR_FR"
Sys.setenv(
"GITHUB_PAT_BOULANGERIE_THINKR_FR" = "lefrenchmotdepasseverysecret"
)
pak::pkg_install("git::https://boulangerie.thinkr.fr/mygroup/mysubgroup/mypackage")
#> Error: ! error in pak subprocess
#> Caused by error:
#> ! Could not solve package dependencies:
#> * git::https://boulangerie.thinkr.fr/mygroup/mysubgroup/mypackage: ! pkgdepends resolution error for
#> git::https://boulangerie.thinkr.fr/mygroup/mysubgroup/mypackage.
#> Caused by error:
#> ! Failed to download 'DESCRIPTION' from git repo at
#> <https://boulangerie.thinkr.fr/mygroup/mysubgroup/mypackage>.
#> Caused by error in `stop(http_error(resp))`:
#> ! Unauthorized (HTTP 401).
pd <- pkgdepends::new_pkg_deps("git::https://boulangerie.thinkr.fr/mygroup/mysubgroup/mypackage")
pd$solve()
pd$draw()
#> Error: ! Could not solve package dependencies:
#> * git::https://boulangerie.thinkr.fr/mygroup/mysubgroup/mypackage: ! pkgdepends resolution error for
#> git::https://boulangerie.thinkr.fr/mygroup/mysubgroup/mypackage.
#> Caused by error:
#> ! Failed to download 'DESCRIPTION' from git repo at
#> <https://boulangerie.thinkr.fr/mygroup/mysubgroup/mypackage>.
#> Caused by error in `stop(http_error(resp))`:
#> ! Unprocessable Entity (WebDAV; RFC 4918) (HTTP 422).
# Control with remotes to make sur the TOKEN is valid
options(
remotes.git_credentials = git2r::cred_user_pass(
username = "gitlab-ci-token",
password = Sys.getenv("GITHUB_PAT_boulangerie_THINKR_FR")
)
)
remotes::install_git("https://boulangerie.thinkr.fr/mygroup/mysubgroup/mypackage")
#> Downloading git repo https://boulangerie.thinkr.fr/mygroup/mysubgroup/mypackage
#> Registered S3 methods overwritten by 'callr':
#> method from
#> format.callr_status_error
#> print.callr_status_error
#> ── R CMD build ─────────────────────────────────────────────────────────────────
#> * checking for file ‘/tmp/RtmpkTHZEZ/file7cca331d9c4/DESCRIPTION’ ... OK
#> * preparing ‘mypackage’:
#> * checking DESCRIPTION meta-information ... OK
#> * checking for LF line-endings in source and make files and shell scripts
#> * checking for empty or unneeded directories
#> * building ‘mypackage_0.0.1.tar.gz’
#> Installing package into '/home/bob/R/x86_64-pc-linux-gnu-library/4.3'
#> (as 'lib' is unspecified) Created on 2024-03-13 with reprex v2.1.0 Session infosessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.3.2 (2023-10-31)
#> os Pop!_OS 22.04 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz Europe/Amsterdam
#> date 2024-03-13
#> pandoc 3.1.1 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> callr 3.7.5 2024-02-19 [1] CRAN (R 4.3.2)
#> cli 3.6.2 2023-12-11 [1] CRAN (R 4.3.2)
#> curl 5.2.1 2024-03-01 [1] CRAN (R 4.3.2)
#> desc 1.4.3 2023-12-10 [1] CRAN (R 4.3.2)
#> digest 0.6.35 2024-03-11 [1] CRAN (R 4.3.2)
#> evaluate 0.23 2023-11-01 [1] CRAN (R 4.3.2)
#> fansi 1.0.6 2023-12-08 [1] CRAN (R 4.3.2)
#> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.1)
#> filelock 1.0.3 2023-12-11 [1] CRAN (R 4.3.2)
#> fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.1)
#> git2r 0.33.0 2023-11-26 [1] CRAN (R 4.3.2)
#> gitcreds 0.1.2 2022-09-08 [1] CRAN (R 4.3.1)
#> glue 1.7.0 2024-01-09 [1] CRAN (R 4.3.2)
#> htmltools 0.5.7 2023-11-03 [1] CRAN (R 4.3.2)
#> knitr 1.45 2023-10-30 [1] CRAN (R 4.3.2)
#> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.3.2)
#> lpSolve 5.6.20 2023-12-10 [1] CRAN (R 4.3.2)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.1)
#> pak 0.7.1.9000 2024-03-13 [1] local
#> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.1)
#> pkgbuild 1.4.3 2023-12-10 [1] CRAN (R 4.3.2)
#> pkgcache 2.2.1 2023-12-10 [1] CRAN (R 4.3.2)
#> pkgdepends 0.7.1 2023-12-10 [1] CRAN (R 4.3.2)
#> processx 3.8.3 2023-12-10 [1] CRAN (R 4.3.2)
#> ps 1.7.6 2024-01-18 [1] CRAN (R 4.3.2)
#> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.3.1)
#> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.3.1)
#> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.3.1)
#> R.oo 1.26.0 2024-01-24 [1] CRAN (R 4.3.2)
#> R.utils 2.12.3 2023-11-18 [1] CRAN (R 4.3.2)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.1)
#> remotes 2.4.2.1 2023-07-18 [1] CRAN (R 4.3.1)
#> reprex 2.1.0 2024-01-11 [1] CRAN (R 4.3.2)
#> rlang 1.1.3 2024-01-10 [1] CRAN (R 4.3.2)
#> rmarkdown 2.26 2024-03-05 [1] CRAN (R 4.3.2)
#> rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.3.1)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.1)
#> styler 1.10.2 2023-08-29 [1] CRAN (R 4.3.1)
#> utf8 1.2.4 2023-10-22 [1] CRAN (R 4.3.2)
#> vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.3.2)
#> withr 3.0.0 2024-01-16 [1] CRAN (R 4.3.2)
#> xfun 0.42 2024-02-08 [1] CRAN (R 4.3.2)
#> yaml 2.3.8 2023-12-11 [1] CRAN (R 4.3.2)
#>
#> [1] /home/bob/R/x86_64-pc-linux-gnu-library/4.3
#> [2] /opt/R/4.3.2/lib/R/library
#>
#> ────────────────────────────────────────────────────────────────────────────── |
Actually I encounter the errors with gitlab.com gitcreds::gitcreds_cache_envvar("https://gitlab.com")
#> [1] "GITHUB_PAT_GITLAB_COM"
Sys.setenv(
"GITHUB_PAT_GITLAB_COM" = "lefrenchmotdepasseverysecret"
)
pak::pkg_install("git::https://gitlab.com/antoine120/myprivatepkg")
#> Error: ! error in pak subprocess
#> Caused by error:
#> ! Could not solve package dependencies:
#> * git::https://gitlab.com/antoine120/myprivatepkg: ! pkgdepends resolution error for
#> git::https://gitlab.com/antoine120/myprivatepkg.
#> Caused by error:
#> ! Failed to download 'DESCRIPTION' from git repo at
#> <https://gitlab.com/antoine120/myprivatepkg>.
#> Caused by error in `stop(http_error(resp))`:
#> ! Unauthorized (HTTP 401).
pd <- pkgdepends::new_pkg_deps("git::https://gitlab.com/antoine120/myprivatepkg")
pd$solve()
pd$draw()
#> Error: ! Could not solve package dependencies:
#> * git::https://gitlab.com/antoine120/myprivatepkg: ! pkgdepends resolution error for
#> git::https://gitlab.com/antoine120/myprivatepkg.
#> Caused by error:
#> ! Failed to download 'DESCRIPTION' from git repo at
#> <https://gitlab.com/antoine120/myprivatepkg>.
#> Caused by error in `stop(http_error(resp))`:
#> ! Unprocessable Entity (WebDAV; RFC 4918) (HTTP 422).
# Control with remotes to make sur the TOKEN is valid
options(
remotes.git_credentials = git2r::cred_user_pass(
username = "gitlab-ci-token",
password = Sys.getenv("GITHUB_PAT_GITLAB_COM")
)
)
remotes::install_git("https://gitlab.com/antoine120/myprivatepkg")
#> Downloading git repo https://gitlab.com/antoine120/myprivatepkg
#> Registered S3 methods overwritten by 'callr':
#> method from
#> format.callr_status_error
#> print.callr_status_error
#> ── R CMD build ─────────────────────────────────────────────────────────────────
#> * checking for file ‘/tmp/RtmpIs2L18/file86c8627193d4/DESCRIPTION’ ... OK
#> * preparing ‘myprivatepkg’:
#> * checking DESCRIPTION meta-information ... OK
#> * checking for LF line-endings in source and make files and shell scripts
#> * checking for empty or unneeded directories
#> * building ‘myprivatepkg_0.0.0.9000.tar.gz’
#> Installing package into '/home/bob/R/x86_64-pc-linux-gnu-library/4.3'
#> (as 'lib' is unspecified) Created on 2024-03-13 with reprex v2.1.0 |
@ALanguillaume, it resolved the issue for me by setting the dependency to "gitlab" rather than "git" within
For a private gitlab instance with the PAT "GITHUB_PAT_BOULANGERIE_THINKR_FR" it is:
|
Could you please support
GITLAB_PAT
the same way you supportGITHUB_PAT
? Theremotes
package supports both.pak
is so much faster that right now my workaround is to first clone the gitlab repo and then do apak::local_install()
. I'm happy to have a crack at a PR if you give me some instruction, but also happy for you do do it yourself.Thank you for
pak
, I use it all the time.The text was updated successfully, but these errors were encountered: