remotes
remotes copied to clipboard
Url generated by 'install_gitlab' doesn't exist
Hello !
We use install_gitlab
with our internal gitlab, and it works perfectly until now.
With the new version using api V4, the URL generated doesn't work anymore.
The issue come from gitlab_project_id
. The attribute project_id
is not present in the return, so there is no project id and the URL generated is false. And the Gitlab API doesn't seem to return this attribute when we make a 'commits' call (see the documentation).
By the way, using the same tips as in this function works in my case, and with gitlab.com too.
Why not use utils::URLencode(paste0(username, "/", repo), reserved = TRUE)
instead of the project_id
?
And generate something like this :
https://gitlab.com/api/v4/projects/<username>%2F<project>/repository/archive.tar.gz?sha=<sha>
And thanks for the package, it's very useful !
I am also encountering this problem.
When I execute
remotes::install_gitlab(repo = "<username>/<project>", host = "gitlab.<mydomain>.com", auth_token = gitlab_pat())
I get an error:
Using GitLab PAT from envvar GITLAB_PAT
Error: Failed to install 'unknown package' from GitLab:
cannot open URL 'https://gitlab.<mydomain>.com/api/v4/projects/<username>%2F<project>/repository/files/DESCRIPTION/raw?ref=HEAD'
But I can open the URL in my browser and it returns the package's DESCRIPTION
file, and I have verified that the GITLAB_PAT
is correct when I use it outside of R.
Just to add to this, I see different behaviour from within RStudio and a standalone R session.
In RStudio:
remotes::install_gitlab(repo = "<username>/<project>", host = "gitlab.<mydomain>.com", auth_token = gitlab_pat())
fails and results in:
Using GitLab PAT from envvar GITLAB_PAT
Error: Failed to install 'unknown package' from GitLab:
cannot open URL 'https://gitlab.<mydomain>.com/api/v4/projects/<username>%2F<project>/repository/files/DESCRIPTION/raw?ref=HEAD'
In a standalone R session (same version of R and {remotes}), exactly the same command successfully installs the package. The first part of the console feedback is:
Using GitLab PAT from envvar GITLAB_PAT
Downloading GitLab repo <username>/<project>@HEAD
from URL https://gitlab.<mydomain>.com/api/v4/projects/28/repository/archive.tar.gz?sha=HEAD
Note that the project ID is used in the URL instead of username/project, and the download target is archive.tar.gz
I'm not sure I have the skills to dig further into this because I don't understand what is happening, but I post here in case it helps anyone else move forwards.
I've met the same issue. But install_gitlab
issues in error for both consoles in R studio or R.exe.
RStudio 2022.07.1, with R v4.2.1 under windows and remotes package v2.4.2.