r-lib / remotes

Install R packages from GitHub, GitLab, Bitbucket, git, svn repositories, URLs
https://remotes.r-lib.org/
Other
330 stars 152 forks source link

Failed to install 'unknown package' from GitLab #706

Open ThomUK opened 2 years ago

ThomUK commented 2 years ago

I am experiencing this problem when trying to install from a self-hosted gitlab instance.
I am on R4.2.0, RStudio 2022.02.3 Build 492, and remotes v2.4.2

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'

The URL in the error message loads correctly in the browser.

My comment on the issue linked below details some previous behaviour that enabled me to install through a standalone R session, but not through RStudio. This workaround no longer functions, and the R session now reports the same error. I can no longer install or update any of the packages from our internal server.
[Failed to install 'unknown package' from GitLab](https://github.com/r-lib/remotes/issues/490#issuecomment-1050272559)

The key appears to be the appearance of the project ID in the gitlab V4 API url.
This is the documentation page detailing the API that results in a successful install: https://docs.gitlab.com/ee/api/repositories.html#get-file-archive

The function remote_download.gitlab_remote appears to follow the structure of this API, but the URL that fails is not of this structure. If anyone can give some debugging hints I am happy to dig and work on a solution.

Thank you for maintaining a brilliant package!

ThomUK commented 1 year ago

Just a polite "bump" of this issue. I still have the problem, and judging from other reactions I suspect others do too... My workaround is to clone development packages and build locally, but this is a poor option for other package users who need to install.

Any ideas? Thank you

ThomUK commented 1 year ago

This code, from the tests also fails:

remotes::install_gitlab("jimhester/falsy")

with the message:

> remotes::install_gitlab("jimhester/falsy")
Using GitLab PAT from envvar GITLAB_PAT
Error: Failed to install 'unknown package' from GitLab:
  cannot open URL 'https://gitlab.com/api/v4/projects/jimhester%2Ffalsy/repository/files/DESCRIPTION/raw?ref=HEAD'

The link in the error message opens normally in a browser.

jonathan-g commented 1 year ago

I am seeing the same problem, both for installing a package from a self-hosted instance, and also for the test case remotes::install_gitlab("jimhester/falsy").

If I copy and paste the URL reported in the error message into Firefox, the browser opens the DESCRIPTION file correctly.

I'm using R 4.2.2 and remotes 2.4.2.

williamboman commented 1 year ago

Doing the following solved it for me:

1) ensure GITHUB_PAT is set to a valid GitHub API token (seems to only have been needed when running on GitHub's runners) 2) ensure libcurl-dev is installed 3) ensure remotes was installed with all dependencies:

   install.packages("remotes", dependencies = TRUE)

My understanding is that R curl bindings won't get installed otherwise because it's listed as a Suggested dependency of remotes.

jonathan-g commented 1 year ago

Did you mean to leave a comment about solving a GitHub problem in an issue about a GitLab (not GitHub) API problem?

williamboman commented 1 year ago

Did you mean to leave a comment about solving a GitHub problem in an issue about a GitLab (not GitHub) API problem?

Skip step 1 if not installing from GitHub. I figured the underlying HTTP/TCP issue applies regardless of which remote it tries to connect to.

ThomUK commented 1 year ago

Did you mean to leave a comment about solving a GitHub problem in an issue about a GitLab (not GitHub) API problem?

Skip step 1 if not installing from GitHub. I figured the underlying HTTP/TCP issue applies regardless of which remote it tries to connect to.

This didn't solve the problem for me, but I don't have the machine admin rights needed to install libcurl-dev

gaborcsardi commented 10 months ago

I suggest you try the pak package for GitLab repos, it should work better.

ThomUK commented 6 months ago

Just a quick update - I have tried pak and that also didn't work. I'm still investigating.

trafficonese commented 2 months ago

I am also having problems with our own Gitlab istance.

Previously I could install a gitlab package in my CI-Runners like this: remotes::install_gitlab(repo = 'group/repo@develop', auth_token = 'glpat-[MASKED]', host = 'gitlab.mycompany.eu')

But we upgraded now to Gitlab v17 and now I am seeing this error aswell:

Fehler: Failed to install 'unknown package' from GitLab:
kann URL 'https://gitlab.mycompany.eu/api/v4/projects/group%2Frepo/repository/files/DESCRIPTION/raw?ref=master' nicht öffnen

But I can open that URL in the browser and see the DESCRIPTION file..

I also tried pak without success, but I am not sure if I tried it correctly.


My current solution is back to basics with git and R CMD using this:

RUN apt-get update && apt-get install -y git
RUN git clone --branch develop https://user:glpat-*****@gitlab.mycompany.eu/group/repo.git /root/repo
RUN R CMD build --no-build-vignettes --no-manual /root/repo
RUN R CMD INSTALL /root/repo
ThomUK commented 2 months ago

Also still a problem for me