Skip to content
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

Failed to install 'unknown package' from GitLab #706

Open
ThomUK opened this issue Jun 15, 2022 · 14 comments
Open

Failed to install 'unknown package' from GitLab #706

ThomUK opened this issue Jun 15, 2022 · 14 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@ThomUK
Copy link

ThomUK commented Jun 15, 2022

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](#490 (comment))

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 ThomUK changed the title Failed to install 'unknown package' from GitLab - Failed to install 'unknown package' from GitLab Jun 15, 2022
@ThomUK
Copy link
Author

ThomUK commented Feb 21, 2023

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
Copy link
Author

ThomUK commented Feb 21, 2023

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
Copy link

jonathan-g commented Feb 22, 2023

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
Copy link

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
Copy link

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

@williamboman
Copy link

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
Copy link
Author

ThomUK commented Apr 27, 2023

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
Copy link
Member

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

@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label Nov 1, 2023
@ThomUK
Copy link
Author

ThomUK commented Feb 8, 2024

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

@trafficonese
Copy link

trafficonese commented Jun 26, 2024

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
Copy link
Author

ThomUK commented Jun 26, 2024

Also still a problem for me

@GC-repeat
Copy link

I have a similar issue for a package that I have on a private repo on gitlab.com.
If I tried to install it using a token I get the same error message :

remotes::install_gitlab("<user>/<repo>@develop", auth_token = gitlab_pat("token"))
Error: Failed to install 'unknown package' from GitLab:
  cannot open URL 'https://gitlab.com/api/v4/projects/<user>%2F<repo>/repository/files/DESCRIPTION/raw?ref=develop'

Here also, the URL does open in a browser.

Now, if I set the repo to public and try to install without the token then it goes through.

remotes::install_gitlab("<user>/<repo>@develop")
Downloading GitLab repo <user>/<repo>@develop
from URL https://gitlab.com/api/v4/projects/<projectID>/repository/archive.tar.gz?sha=develop

In that case the URL follows the format described in the first comment.

@SusiJo
Copy link

SusiJo commented Oct 25, 2024

Did you use a user-based personal access token or a repository access token?
I've also encountered this error message when using a repository access token, but it works with a user-based PAT.

@GC-repeat
Copy link

I used a repository access token. Indeed, a user-based PAT did work for me too but only when used by itself and not within gitlab_pat().

remotes::install_gitlab("<user>/<repo>@develop", auth_token = gitlab_pat("user_token")) : Error
remotes::install_gitlab("<user>/<repo>@develop", auth_token = "user_token") : Works
remotes::install_gitlab("<user>/<repo>@develop", auth_token = gitlab_pat("repo_token")) : Error
remotes::install_gitlab("<user>/<repo>@develop", auth_token = "repo_token") : Error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

7 participants