Installing non-public packages from Gitlab using devtools :: install_git

My organization recently installed GitLab for us. I figured out how to install R packages from the GitLab server using devtools::install_git , and it works as long as the project is publicly available.

 #* When modeltable project has Public status devtools::install_git('https://mini-me2.lerner.ccf.org/nutterb/modeltable.git') 

However, if I have a package that is listed as Internal or Closed, I cannot install the package without any authentication. At the moment, I did not understand how to authenticate using the URL. Does anyone have experience downloading packages from GitLab?

 #* After changing the 'modeltable' project to Private status devtools::install_git('https://mini-me2.lerner.ccf.org/nutterb/modeltable.git') Preparing installation of modeltable using the Git-URL: https://mini-me2.lerner.ccf.org/nutterb/modeltable.git '/usr/bin/git'clone --depth 1 --no-hardlinks https://mini-me2.lerner.ccf.org/nutterb/modeltable.git /tmp/Rtmp5aj1cU/file24493dc03a32 Error: There seems to be a problem retrieving this Git-URL. 
+15
gitlab r devtools
Dec 05 '14 at 15:25
source share
3 answers

You should try the combination of devtools and getPass .

https://github.com/wrathematics/getPass

 devtools::install_git( "https://gitlab.com/foo/bar.git", credentials = git2r::cred_user_pass("uname", getPass::getPass()) ) 

Where uname is your Gitlab .

+5
Sep 30 '16 at 16:41
source share

I highly recommend switching to the SSH route, and below for that. I found that jumping into SSH was easy, especially with R and RStudio. I am using Windows in the example below. Editing the code that I use in practice is in all the caps.

 creds = git2r::cred_ssh_key("C:\\Users\\MYSELF\\.ssh\\id_rsa.pub", "C:\\Users\\MYSELF\\.ssh\\id_rsa") devtools::install_git("git@gitlab.WORKDOMAIN.com:GITLABGROUP/PACKAGE.git", credentials = creds) 

Two quick additional comments:

  • git2r is imported using devtools, you do not need to install it separately.
  • Also, I don’t think it should be mentioned, but plaintext passwords in your script is a very bad idea.
+6
Jan 13 '17 at 23:45
source share

Per Ciro comment, authentication using

 https://user:password@domain.com/user/repo.git 

does the trick. So the full challenge will be

 devtools::install_git('https://user:password@mini-me2.lerner.ccf.org/nutterb/modeltable.git') 

Please note that there may be security issues when transferring username and password. I am not fully trained in these issues. This works well enough for my purposes because I am authenticated on my network to even see the GitLab server.

+3
Dec 05 '14 at 17:08
source share



All Articles