How to install R package from private repo using devtools install_github?

A more modern solution to this problem is to set your credentials in R using the usethis and credentials packages.

#set config
usethis::use_git_config(user.name = "YourName", user.email = "[email protected]")

#Go to github page to generate token
usethis::create_github_token() 

#paste your PAT into pop-up that follows...
credentials::set_github_pat()

#now remotes::install_github() will work
remotes::install_github("username/privaterepo")

More help at https://happygitwithr.com/common-remote-setups.html#common-remote-setups


Create an access token in: https://github.com/settings/tokens

Check the branch name and pass it to ref

devtools::install_github("user/repo"
                         ,ref="main"
                         ,auth_token = "tokenstring"
                         )

Have you tried setting a personal access token (PAT) and passing it along as the value of the auth_token argument of install_github()?

See ?install_github way down at the bottom (Package devtools version 1.5.0.99).

Tags:

R

Github

Devtools