Devtools::Install_Git Over Ssh

devtools::install_git Over SSH

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:

  • https://github.com/hadley/devtools/issues/796
  • https://github.com/ropensci/git2r/issues/140

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.

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

You could try a combination of the devtools and getPass packages.

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 user name.

How to push git repository through ssh using git2r?

I finally found what I missed. I forgot to install libssh2-1-dev library before installing git2r.

A similar question here.

Install libssh2-1-dev:

sudo apt-get install libssh2-1-dev

Install R package from Atlassian Stash

Using this solution as a starting point, I discovered that you can use devtools with a Stash ssh url:

devtools::install_git("ssh://git@stash.yourdomain.com:1234/project/repo.git")

That will install from the latest commit on the master branch. You can also install a specific branch:

devtools::install_git("ssh://git@stash.yourdomain.com:1234/project/repo.git", branch="develop")

or tag:

devtools::install_git("ssh://git@stash.yourdomain.com:1234/project/repo.git", branch="v1.0")

(note you don't need the tags/ prefix when using a tag)

This will only work if you have SSH keys for your machine on your Stash account. Using the http clone url will not work, because you can't authenticate properly.

Installing a package from private GitLab server on Windows

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
)

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

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).



Related Topics



Leave a reply



Submit