How to use `remotes::install_gitlab` to install from a branch?

1.1k Views Asked by At

I wanted to install the interp package from the "spline" branch in the Gitlab repository at https://gitlab.aau.at/agebhard/interp . When I select that branch on the web page, the URL changes to https://gitlab.aau.at/agebhard/interp/-/tree/spline . However, using that URL in the obvious way gives an error:

remotes::install_gitlab("agebhard/interp", 
                        subdir = "-/tree/spline", 
                        host = "https://gitlab.aau.at")
#> Error: Failed to install 'unknown package' from GitLab:
#>   cannot open URL 'https://gitlab.aau.at/api/v4/projects/agebhard%2Finterp/repository/files/-%2Ftree%2Fspline%2FDESCRIPTION/raw?ref=HEAD'

Created on 2022-02-09 by the reprex package (v2.0.1.9000)

I ended up cloning the whole repository and then using git branch to select the branch, and installing locally. But surely remotes::install_gitlab() would offer a way to install directly from a branch? The install_github() function has ref to select a branch or tag, but I don't see an equivalent of that argument in install_gitlab().

2

There are 2 best solutions below

0
danlooo On BEST ANSWER

You can use just install_git

remotes::install_git(
  url = "https://gitlab.aau.at/agebhard/interp.git",
  ref = "spline"
)
0
user2554330 On

Thanks to @danlooo's answer and some debuggging, I worked out the right way to use install_gitlab itself. You just put the branch at the end of the name with an @ sign, e.g.

remotes::install_gitlab("agebhard/interp@spline", 
                        host = "gitlab.aau.at")