use pkgdepends syntax for gitlab remotes with pak - #2339
Open
kevinushey wants to merge 1 commit into
Open
Conversation
renv formatted GitLab records for pak using its own remote syntax, e.g. 'gitlab@host::group/project', which pkgdepends cannot parse -- so install() and restore() failed for packages hosted on a self-hosted GitLab instance. Sub-directories were also formatted as 'gitlab::group/project/subdir', which pkgdepends silently misreads as project 'subdir' within group 'group/project'. Format GitLab remotes for pak using pkgdepends' own syntax instead, and translate user-provided specs on the install() path as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2180.
Problem
renv_record_format_remote(pak = TRUE)formats GitLab records using renv's ownremote syntax, which pkgdepends cannot parse:
pkgdepends' GitLab grammar (
pkgdepends:::gitlab_rx()) is:so there are two bugs here, both confirmed by passing renv's output to
pkgdepends:::parse_pkg_ref():Custom host: hard failure.
gitlab@host::is unparseable, which is theCannot parse packageerror reported in renv::restore does not resolve packages on self-hosted Gitlab instances when usingpak#2180. Note the host has to bespelled as a URL:
gitlab::gitlab.example.de/group/repoparses"successfully", but treats the hostname as the first path component and so
looks for the project on gitlab.com.
Sub-directories: silent misparse. renv emits
gitlab::group/repo/subdir@sha, which pkgdepends reads as projectsubdirwithin group
group/repo-- installing the wrong thing rather than erroring.This doesn't reproduce for everyone because packages installed by pak carry a
valid
RemotePkgRefin their DESCRIPTION, whichrenv_record_format_remote()returns early and unchanged. The failure only affects lockfile records generated
by renv's own resolver -- which is the lockfile shape reported in #2180.
renv::install("gitlab@host::...")was broken the same way on a separate path:renv_pak_install()passes raw user specs to pak untouched, apart from the:->/sub-directory fixup from #2011, which is itself wrong for GitLab.Changes
renv_record_format_remote_pak_gitlab()formats GitLab records inpkgdepends' syntax. It always includes
https://<host>/(also forgitlab.com, which removes the sub-directory ambiguity), uses
/-/<subdir>,and keeps an explicit
<package>=prefix, since pkgdepends would otherwiseinfer the package name from the last path component.
renv_pak_remote()translates user-provided GitLab specs on theinstall()path. Specs renv can't parse, and merge-request specs (
#42, which has nopkgdepends equivalent), are passed through unchanged so that pak can report
the problem itself.
Validation
Every generated remote now round-trips through
pkgdepends:::parse_pkg_ref()with the expected url / subdir / commitish /package.
End-to-end against gitlab.com with pak enabled:
install()->snapshot()->
restore(), plus arestore()from a renv-resolved record with noRemotePkgRef(the shape from the issue). Both install correctly, includingthe subgroup case
renv-group/renv-subgroup/subpackage. The self-hosted hostitself can only be validated at the parse layer, which is where the reported
error is raised (
get_remote_types(refs)).Not addressed
Two adjacent cases fail for the same reason, but need decisions beyond the
scope of this fix:
GitHub Enterprise.
github@host::user/repois equally unparseable, andgithub::has no host slot in pkgdepends at all; the only route ispkg=git::https://host/user/repo.git@sha. That needs host translation(renv records an API host, e.g.
github.example.com/api/v3) andgit::supports no sub-directory.
tests/testthat/test-records.R:208currentlyasserts the broken output.
Bitbucket, svn. pkgdepends has no such sources
(
Unknown package source: "bitbucket"), so these could only work via agit::URL rewrite.