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

[pak] Use pak for package installation #1210

Open
hadley opened this issue Apr 26, 2023 · 9 comments
Open

[pak] Use pak for package installation #1210

hadley opened this issue Apr 26, 2023 · 9 comments
Labels
feature a feature request or enhancement install 🧺 update ⬆️
Milestone

Comments

@hadley
Copy link
Member

hadley commented Apr 26, 2023

Related issues:

@hadley hadley added the feature a feature request or enhancement label Apr 26, 2023
@kevinushey
Copy link
Collaborator

Note that partial support is available if one sets in their .Renviron:

RENV_CONFIG_PAK_ENABLED = TRUE

But we'll probably want to scope out what work needs to be done to let us turn this on by default.

@rpodcast

This comment was marked as off-topic.

@eitsupi

This comment was marked as off-topic.

@hadley

This comment was marked as off-topic.

@mnlang
Copy link

mnlang commented Jan 16, 2025

I'm encountering a problem with renv::restore() when using pak with a Remotes section in the DESCRIPTION file that includes dependencies on a self-maintained GitLab instance, which, to my knowledge, has not been reported.

Everything works correctly without these dependencies when setting RENV_CONFIG_PAK_ENABLED = TRUE and directly installing the package via:

pak::pkg_install("gitlab::https://boulangerie.thinkr.fr/mygroup/mysubgroup/mypackage")

as described in this comment, runs as well.

It seems that it cannot resolve to the GitLab instance, as it throws the error ! Could not solve package dependencies and attempts to download the DESCRIPTION files from gitlab.com:

Caused by error: 
! Failed to download DESCRIPTION from git repo at
<https://gitlab.com/...

@kevinushey
Copy link
Collaborator

Any chance you could provide a standalone, reproducible example?

@mnlang
Copy link

mnlang commented Jan 16, 2025

I'm sorry, but providing a standalone, reproducible example on a company GitLab instance is rather difficult. However, I started from scratch and, to my surprise, encountered different error messages. Here's what I tried:

First Attempt Using pak

After successfully installing via:

pak::pkg_install("gitlab::https://gitlab.company.com/user/demopackage2")
renv::snapshot()

The renv.lock file appears as follows:

{
  "R": {
    "Version": "4.1.2",
    "Repositories": [
      {
        "Name": "CRAN",
        "URL": "https://cloud.r-project.org"
      }
    ]
  },
  "Packages": {
    "demopackage2": {
      "Package": "demopackage2",
      "Version": "0.0.0.9000",
      "Source": "GitLab",
      "RemoteType": "gitlab",
      "RemoteUrl": "https://gitlab.company.com/user/demopackage2.git",
      "RemotePkgRef": "gitlab::https://gitlab.company.com/user/demopackage2",
      "RemoteRef": "HEAD",
      "RemoteSha": "6a013a17b0898d52289c6cd370011a50da29792a",
      "RemoteHost": "gitlab.company.com",
      "RemoteRepo": "demopackage2",
      "RemoteUsername": "user",
      "Hash": "0608030528c9f1423fb36ab185cdaa4d"
    },
    "renv": {
      "Package": "renv",
      "Version": "1.0.3",
      "Source": "Repository",
      "Repository": "CRAN",
      "Requirements": [
        "utils"
      ],
      "Hash": "41b847654f567341725473431dd0d5ab"
    }
  }
}

However, the following error occurs when calling renv::restore:

! Using bundled GitHub PAT. Please add your own PAT using `gitcreds::gitcreds_set()`.
Error:                                                                
! error in pak subprocess
Caused by error: 
! Could not solve package dependencies:
* user/demopackage2@HEAD: ! pkgdepends resolution error for user/demopackage2@HEAD.
Caused by error: 
! Can't find GitHub repo user/demopackage2.
Type .Last.error to see the more details.
Traceback (most recent calls last):
6: renv::restore()
5: renv_pak_restore(lockfile = lockfile, packages = packages, exclude = exclude, 
       project = project)
4: pak$pkg_install(remotes)
3: remote(function(...) get("pkg_install_make_plan", asNamespace("pak"))(...), 
       list(pkg = pkg, lib = lib, upgrade = upgrade, ask = ask, 
           start = start, dependencies = dependencies, loaded = loaded_packages(lib)))
2: err$throw(res$error)
1: base::stop(cond)

Second Attempt Using pak

Alternatively, after successful installation via:

pak::pkg_install("git::https://gitlab.company.com/user/demopackage2.git")
renv::snapshot()

The renv.lock file appears as follows:

{
  "R": {
    "Version": "4.1.2",
    "Repositories": [
      {
        "Name": "CRAN",
        "URL": "https://cloud.r-project.org"
      }
    ]
  },
  "Packages": {
    "demopackage2": {
      "Package": "demopackage2",
      "Version": "0.0.0.9000",
      "Source": "git",
      "RemoteType": "git",
      "RemoteUrl": "https://gitlab.company.com/user/demopackage2.git",
      "RemotePkgRef": "git::https://gitlab.company.com/user/demopackage2.git",
      "RemoteRef": "HEAD",
      "RemoteSha": "6a013a17b0898d52289c6cd370011a50da29792a",
      "RemoteHost": "gitlab.company.com",
      "RemoteRepo": "demopackage2",
      "RemoteUsername": "user",
      "Hash": "8538f3274f87fc9bf3793017f7d1ee6a"
    },
    "renv": {
      "Package": "renv",
      "Version": "1.0.3",
      "Source": "Repository",
      "Repository": "CRAN",
      "Requirements": [
        "utils"
      ],
      "Hash": "41b847654f567341725473431dd0d5ab"
    }
  }
}

And the following error occurs when calling renv::restore:

> renv::restore()
! Using bundled GitHub PAT. Please add your own PAT using `gitcreds::gitcreds_set()`.
Error:                                                                
! error in pak subprocess
Caused by error: 
! Could not solve package dependencies:
* user/demopackage2@HEAD: ! pkgdepends resolution error for user/demopackage2@HEAD.
Caused by error: 
! Can't find GitHub repo user/demopackage2.
Type .Last.error to see the more details.
Traceback (most recent calls last):
6: renv::restore()
5: renv_pak_restore(lockfile = lockfile, packages = packages, exclude = exclude, 
       project = project)
4: pak$pkg_install(remotes)
3: remote(function(...) get("pkg_install_make_plan", asNamespace("pak"))(...), 
       list(pkg = pkg, lib = lib, upgrade = upgrade, ask = ask, 
           start = start, dependencies = dependencies, loaded = loaded_packages(lib)))
2: err$throw(res$error)
1: base::stop(cond)

Installation via remotes

Again, successful installation now via:

remotes::install_gitlab("user/demopackage2", host = "https://gitlab.company.com")

The snapshot looks like this:

{
  "R": {
    "Version": "4.1.2",
    "Repositories": [
      {
        "Name": "CRAN",
        "URL": "https://cloud.r-project.org"
      }
    ]
  },
  "Packages": {
    "demopackage2": {
      "Package": "demopackage2",
      "Version": "0.0.0.9000",
      "Source": "GitLab",
      "RemoteType": "gitlab",
      "RemoteHost": "https://gitlab.company.com",
      "RemoteRepo": "demopackage2",
      "RemoteUsername": "user",
      "RemoteRef": "HEAD",
      "RemoteSha": "6a013a17b0898d52289c6cd370011a50da29792a",
      "Hash": "82cef80084224e734eb15b302e0b7fb6"
    },
    "renv": {
      "Package": "renv",
      "Version": "1.0.3",
      "Source": "Repository",
      "Repository": "CRAN",
      "Requirements": [
        "utils"
      ],
      "Hash": "41b847654f567341725473431dd0d5ab"
    }
  }
}

And the following error is produced:

renv::restore()

! Using bundled GitHub PAT. Please add your own PAT using `gitcreds::gitcreds_set()`.
Error:                                                                
! error in pak subprocess
Caused by error: 
! Could not solve package dependencies:
* user/demopackage2@HEAD: ! pkgdepends resolution error for user/demopackage2@HEAD.
Caused by error: 
! Can't find GitHub repo user/demopackage2.
Type .Last.error to see the more details.
Traceback (most recent calls last):
6: renv::restore()
5: renv_pak_restore(lockfile = lockfile, packages = packages, exclude = exclude, 
       project = project)
4: pak$pkg_install(remotes)
3: remote(function(...) get("pkg_install_make_plan", asNamespace("pak"))(...), 
       list(pkg = pkg, lib = lib, upgrade = upgrade, ask = ask, 
           start = start, dependencies = dependencies, loaded = loaded_packages(lib)))
2: err$throw(res$error)
1: base::stop(cond)

Finally, by removing RENV_CONFIG_PAK_ENABLED = TRUE from the .Renviron file, it works:

renv::restore()

The following package(s) will be updated:

# GitLab ---------------------------------------------------------------------
- demopackage2   [* -> user/demopackage2@HEAD]

Do you want to proceed? [Y/n]: Y

# Downloading packages -------------------------------------------------------
- Downloading demopackage2 from GitLab ...      OK [602 bytes in 0.38s]
Successfully downloaded 1 package in 0.42 seconds.

# Installing packages --------------------------------------------------------
- Installing demopackage2 ...                   OK [built from source and cached in 0.38s]

@alethor
Copy link

alethor commented Jan 22, 2025

Can confirm that I also had the same issue as @mnlang for a private repo hosted on gitlab.com

@kevinushey
Copy link
Collaborator

Can you please file a separate issue with details, so that this doesn't get lost?

Is there any chance this could be reproduced using an R package available on a publicly-visible Gitlab project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement install 🧺 update ⬆️
Projects
None yet
Development

No branches or pull requests

6 participants