remotes icon indicating copy to clipboard operation
remotes copied to clipboard

Url generated by 'install_gitlab' doesn't exist

Open LuminusDev opened this issue 4 years ago • 3 comments

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 !

LuminusDev avatar Apr 06 '20 08:04 LuminusDev

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.

jonathan-g avatar Jul 20 '21 04:07 jonathan-g

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.

ThomUK avatar Feb 24 '22 21:02 ThomUK

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.

DDorch avatar Sep 01 '22 12:09 DDorch