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

renv and private GitLab packages #1133

Open
cbligaard opened this issue Jan 27, 2025 · 1 comment
Open

renv and private GitLab packages #1133

cbligaard opened this issue Jan 27, 2025 · 1 comment

Comments

@cbligaard
Copy link

Hi rsconnect team,

I am having an issue with deploying an R shiny app to RStudio Connect. I am using renv for managing the packages, which include a mix of sources like CRAN, public Github repos and a self-hosted GitLab repo. The latter is where problems arise.

I can install these packages in R without issues – either by downloading a local tar.gz and installing from source or by generating a PAT in GitLab and following the answer here: https://stackoverflow.com/questions/62772833/use-renv-for-private-gitlab-package. If I install from source, it is easy for my colleagues to update their local renv as well.

However, when I want to deploy the package, I run into a series of issues. With local sourced packages, I cannot write the manifest:

Error in `createAppManifest()` at rsconnect/R/deployApp.R:648:2:
! All packages must be installed from a reproducible location.
✖ Can't re-install packages installed from source: <package>.

With packages from our in-house GitLab, I get the following messages during install:

Installing <package> (<version>) ...
curl: HTTP 404 <address_of_repo>//api/v4/projects/<package1>%2F<package2>/repository/archive?sha=<sha>
curl: (22) The requested URL returned error: 404
…
FAILED
Error in value[[3L]](cond): Failed to download package from URL:
- <address_of_repo>//api/v4/projects/<package1>%2F<package2>/repository/archive?sha=<sha>'
- Reason: Error in doTryCatch(return(expr), name, parentenv, handler): Download failure.

I am using R 4.2.0, rsconnect 1.3.4 and renv 1.0.11.

I came across the issue Packrat unable to restore package from private Gitlab · Issue #625 · rstudio/packrat, but that seems to have been related to a required update to allow gitlab as a source. I have also been reading on R Package Management – Posit Connect Documentation Version 2024.12.0, but I didn’t find any solutions that worked – and I don’t have the rights to modify the /etc/rstudio-connect/rstudio-connect.gcfg file.

Any help would be greatly appreciated.

Thanks,
Christina

@aronatkins
Copy link
Contributor

In your development environment, you'll want to use remotes::install_gitlab() rather than remotes::install_git() (or the devtools equivalent). This makes sure that the installed package is annotated as coming from GitLab in a way that rsconnect can consume. Neither .tar.gz installation or remotes::install_git() provide the right breadcrumbs.

You found the right documentation (https://docs.posit.co/connect/admin/r/package-management/#from-private-git-repositories and https://docs.posit.co/connect/admin/content-management/git-backed/#private-repos).

Posit Connect uses Git credentials managed by the server configuration. Folks often have a "service account" that they use for this type of programmatic access. Unfortunately, you'll need the folks who manage your Connect server to add this configuration.

The 404 error you're seeing probably indicates that an authenticated request is not happening.

Typically, the Connect configuration to enable this ends up looking like:

[GitCredential]
Host = "gitlab.com"
Username = "serviceAccountName"
Password = "encryptedServiceAccountCredential"
Protocol = "https"

;; The R.RestoreUsesGitCredentials is enabled by default in Connect 2024.09; earlier releases 
;; need to enable the feature.
[R]
RestoreUsesGitCredentials = true

If you aren't going to be able to have your Connect configuration modified, the other option is to "release" your package and host it on some R package repository that is visible to Connect. Many of our customers use the Posit Package Manager for this, but any CRAN-like R package repository is suitable.

Please reach out to our support team if your Connect administrator needs help making changes to the Connect configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants