Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

r - devtools::install_git Over SSH

I've written an R package that I keep in a (bare) git repository on an SSH server, and I want to be able to install it on a local machine without needing to clone the repository by hand.

I've attempted the following:

devtools::install_git("ssh://user_name@remote/path/to/repository")

but I get the error

    Downloading git repo ssh://user_name@remote/path/to/repository
    Error in git2r::clone(x$url, bundle, progress = FALSE) : 
    Error in 'git2r_clone': Failed to start SSH session: Unable to exchange encryption keys

I'm on a Windows 7 machine, using R 3.1.2, git2r version 0.11.0 and devtools version 1.9.1. Any help would be greatly appreciated. Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Ran into this issue myself. I know this question is a bit old, but for anybody else running into the same issue (like me), here's what I've found.

The Problem

Likely you don't have the library that git2r (the package that devtools uses to interact with git) uses to communicate over SSH.

The Solution

Install it. The example below assumes Ubuntu.

sudo apt-get install libssh2-1 libssh2-1-dev

git2r uses a library called LibSSH2 to enable transport over SSH. You can install it using your package manager if you're on Linux. NOTE if you're on Windows, git2r does not support the SSH protocol yet :/ As of git2r version 0.11.0 (which uses an updated version of libgit2) it looks like SSH is supported on Windows as well. As of this edit, the newest version of git2r is 0.15, so if you don't have SSH support on Windows, try updating git2r (shout out to zeehio for the news).

After you've installed LibSSH2 you'll need to reinstall the git2r package to enable SSH transport (since it's enabled/disabled during the package build).

Sources

Issues on GitHub:

Why do I need LibSSH2 at all? git doesn't use it, right?

You're right! git doesn't use it (to my knowledge). However, libgit2, which is the pure C git API implementation that git2r uses, does.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...