简体   繁体   中英

Installing a package from private GitLab server on Windows

I am struggling with installing a package from a GitLab repository on a Windows computer.

I found different hints but still have problems to install my package from GitLab. First of all, I generated a public and private key with puttygen.exe. The files need to be changed afterwards, I had to remove comments and stuff so they look like my the file on my Unix system. So now, both public and private key files have just a single line.

I tried to install my package via devtools::install_git which takes very long and I get the error message

Error: Failed to install 'unknown package' from Git:
  Error in 'git2r_remote_ls': Failed to authenticate SSH session: Unable to send userauth-publickey request

And with devtools::install_gitlab I get a different error message and I somehow have the feeling, the link which gets generated doesn't fit to my GitLab server.

Error: Failed to install 'unknown package' from GitLab:
  cannot open URL 'https://gitlab.rlp.net/api/v4/projects/madejung%2FMQqueue.git/repository/files/DESCRIPTION/raw?ref=master'

My complete code to test at the moment is

creds <- git2r::cred_ssh_key(publickey="~/.ssh/id_rsa_gitlab.pub",
                             privatekey="~/.ssh/id_rsa_gitlab")
devtools::install_git(
  url='git@gitlab.rlp.net:madejung/MQqueue.git',
  quiet=FALSE, 
  credentials=creds)

devtools::install_gitlab(
  repo='madejung/MQqueue.git',
  host='gitlab.rlp.net',
  quiet=FALSE, 
  credentials=creds
)

My id_rsa_gitlab.pub file looks like this and is just a single line:

ssh-rsa AAAA....fiwbw== rsa-key-20200121

The id_rsa_gitlab file has just the code:

AAABA.....3WNSIAGE=

Update

On my Mac system it works as expected after installing the libssh2 library via homebrew and and recompiling git2r with install.packages("git2r", type = "source") .

So the working code on my machine is:

creds <- git2r::cred_ssh_key(publickey="~/.ssh/id_rsa_gitlab.rlp.net.pub",
                             privatekey="~/.ssh/id_rsa_gitlab.rlp.net")
devtools::install_git(
  url='git@gitlab.rlp.net:madejung/MQqueue.git',
  quiet=FALSE, 
  credentials=creds
)

For some strange reason, the devtools::install_git call needs about a minute to fail in the end. I have no idea where the problem here is.

After struggling for almost a day, I found a solution I can live with...

I first created a PAT (Personal Access Token) in my gitlab account and granted full API access. For some reason the read_only access didn't worked and I am now tired to figure out what the problem is.

After this I had still problems to install my package and for some reason, the wininet setting for downloading doesn't work.

I used the command capabilities("libcurl") to check if libcurl is available on my windows, which was and tried to overwrite wininet to libcurl by using method='libcurl' in the install function. Somehow, this was not enough so I overwrote the options variable download.file.method directly.

options("download.file.method"='libcurl')
devtools::install_gitlab(
  repo='madejung/MQqueue',
  auth_token='Ho...SOMETHING...xugzb',
  host='gitlab.rlp.net',
  quiet=FALSE, force=TRUE
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM