Install R Packages From GitLab
The remotes package makes it possible to install packages from different sources – including GitLab.
For the sake of argument, let us assume my GitLab is hosted at https://gitlab.myorg.com and that I want to install an R package whose repository https://gitlab.myorg.com/path/to/package.
This can be done with the command
remotes::install_gitlab("path/to/package", host = "gitlab.myorg.com", dependencies = TRUE)
To authenticate against GitLab’s API a personal access token is needed:
Click on your user profile in the upper right corner and select “Settings”.
Choose “Access Tokens” and create a token with “Scopes”
The default option in
remotes::install_gitlab is to look for such a token in an environment variable called
To make such a variable available in all R sessions it can be saved in the user
This file can be accessed directly from R:
With a token
<token> it is entered in
This package may also have dependencies that are located on GitLab.
These should be listed in unofficial
Remotes field in the
DESCRIPTION file as explained in this devtools vignette:
A package along with its dependencies can then be installed with this command:
devtools::install(dependencies = TRUE, host = "https://gitlab.myorg.com")
dependencies argument ensures that packages in the
Suggests fields of
DESCRIPTION gets installed as well.