Getting `unsupported URL protocol` when using SSH authentication with git2r::clone in R

夙愿已清 提交于 2020-03-23 07:57:49

问题


I'm trying to clone a private repo with git2r::clone via SSH (not HTTPS protocol) in R by doing

git2r::clone("git@git.server.com:team_name/repo_name.git", "~/dev/")

but, I keep getting

Error in 'git2r_clone': unsupported URL protocol

What could be wrong?

I am authenticated to the repo via SSH and can clone using the same URL in the command line with git clone url. I would like to avoid using https and entering my credentials into the URL.

I made sure to install libssh2 per this answer


回答1:


This can happen if your git2r installation does not support SSH and therefore can't parse git SSH URLs.

You can confirm by running libgit2_features() in R.

If SSH is disabled, you will see

$threads
[1] TRUE

$https
[1] TRUE

$ssh
[1] FALSE

To fix this, make sure you have installed libssh2 and libgit2. In my case, I had libssh2, but I was still missing libgit2. On a Mac, you can do

brew install libssh2 and brew install libgit2.

After that, re-install git2r from source with

install.packages("git2r", type="source", configure.vars="autobrew=yes")

Reload git2r with library(git2r). Now if you run libgit2_features() in R, you should see ssh TRUE



来源:https://stackoverflow.com/questions/60176959/getting-unsupported-url-protocol-when-using-ssh-authentication-with-git2rclo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!