pak icon indicating copy to clipboard operation
pak copied to clipboard

Feature Request: "host" argument for installing from self-hosted gitlab

Open sklas opened this issue 3 months ago • 6 comments

Hi, I am trying to install a package from our self-hosted Gitlab instance. The base install.packages function recognizes this format: "gitlab@<self-hosted URL>::<project-path>/<repository>, however, this seems not possible with pak. I would really like this option to use it with renv. It works when installing the package as a git repository, but the gitlab option would be more convenient.

sklas avatar Sep 16 '25 12:09 sklas

The base install.packages function recognizes this format: "gitlab@<self-hosted URL>::/,

Can you please show an example with install.packages for that?

gaborcsardi avatar Sep 16 '25 12:09 gaborcsardi

You can probably use it as a git repo, e.g. this works for me:

pak::pkg_install("git::https://gitlab.com/gaborcsardi/cli.git", lib = tempfile())
→ Will install 1 package.
→ The package (0 B) is cached.
+ cli   3.5.0.9000 👷‍♂️🔧
ℹ No downloads are needed, 1 pkg is cached
✔ Installed cli 3.5.0.9000 (git::https://gitlab.com/gaborcsardi/cli.git@bc50350) (40ms)
✔ 1 pkg: added 1 [2.1s]

gaborcsardi avatar Sep 16 '25 12:09 gaborcsardi

This works:

install.packages("[email protected]::r-packages/bookmark")

While this is the output with pak:

pak::pkg_install("[email protected]::r-packages/bookmark")
Error:
! ! error in pak subprocess
Caused by error in `get_remote_types(refs)`:
! Cannot parse package: [email protected]::r-packages/bookmark.
ℹ See `?pkgdepends::pkg_refs()` for supported package sources.
Show Traceback

The option to install it as a git repo works as expected.

sklas avatar Sep 16 '25 12:09 sklas

That does not work for me, and ?install.packages() does not mention gitlab at all.

❯ install.packages("[email protected]::r-packages/bookmark")
Installing package into ‘/Users/gaborcsardi/Library/R/arm64/4.5/library’
(as ‘lib’ is unspecified)
Warning message:
package ‘[email protected]::r-packages/bookmark’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages

Maybe renv replaces install.packages() with its own version?

Btw. this should work as well, IDK if it is any better, but this is the way to specify the host for gitlab packages:

pak::pkg_install("gitlab::https://gitlab.com/gaborcsardi/cli", lib = tempdir())

gaborcsardi avatar Sep 16 '25 12:09 gaborcsardi

It seems that the formats/remotes definition for install.packages is from the remotes package and also used by renv. It is in parts explained here: https://remotes.r-lib.org/articles/dependencies.html

The syntax you proposed works fine for installing packages, but it cannot be restored by renv. It might be more an issue with the integration of pak in renv.

sklas avatar Sep 16 '25 12:09 sklas

It seems that the formats/remotes definition for install.packages is from the remotes package and also used by renv. It is in parts explained here: remotes.r-lib.org/articles/dependencies.html

Again, install.packages() does not support this syntax, it does not support anything but CRAN-like repositories. Only renv does.

FWIW I don't see the gitlab@<self-hosted URL>... syntax on that page.

It might be more an issue with the integration of pak in renv.

It is indeed.

gaborcsardi avatar Sep 16 '25 13:09 gaborcsardi