Install R package from private repository via `token`
Aim
To install a R package that is in a private repository on GitHub.
Prerequisite
- A Github account.
- The account has been authorised to access the private repository where the package is located.
- R and Rstudio.
- R package
devtools. - R package
usethis.
Step by Step
Using a personal access token is probably the easiest way to achieve the aim, although it might not be the safest.
-
Generate a personal access token through the Github. A detailed step by step how to is provided by GitHub help.
-
Open Rstudio.
-
Type
usethis::edit_r_environ()below into the console. The command will open a R environment file named.Renviron. -
Type
auth_token=in the first line. -
Paste the 40 digits token from GitHub on the the right hand side of the equal sign and press enter.
-
Save and close the file.
-
Ctrl + Shift + F10to restart R. -
Type
devtools::install_github("PlantandFoodResearch/pfrticles", auth_token = Sys.getenv("auth_token"))and press enter. The installation should start.
P.S. More information about authentication on GitHub and how organisation repository works