是否可以从私有远程 git 中获取 Cargo 依赖项? [英] Is it possible to have Cargo fetch dependencies from a private remote git?

查看:81
本文介绍了是否可以从私有远程 git 中获取 Cargo 依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一台 ssh 友好的实验室机器上有一个帐户,在那里我存储了许多私人项目,因此我可以从多台计算机访问它们(并且它允许我只使用我的几个私人 Github 存储库来处理多人将要处理的事情).

I have an account on an ssh-friendly lab machine where I store a lot of private projects so I can access them from multiple computers (and it allows me to only use my few private Github repos for things multiple people will work on).

似乎 Rust 可以通过使用诸如

It seems like Rust is well-equipped to fetch local and public data by using things like

[dependencies.foo]
git = "https://github.com/bar/foo"

[dependencies.baz]
path = "/path/to/baz"

但是我还没有找到使用 ssh git 让它工作的方法(例如 git = "git@github.com:bar/foo",或者在我的例子中是 labmachine:bar/foo).如果有帮助的话,我已经设置了无密码/keygen ssh.

But I haven't found a way to get it to work using ssh git (e.g. git = "git@github.com:bar/foo", or in my case labmachine:bar/foo). I have passwordless/keygen ssh set up, if that helps.

如果它不存在也没什么大不了的.目前我只是手动克隆存储库并使用 path = ../foo,只要我保持目录结构相同并记住手动 pull,它就可以工作> 对我所有机器的所有依赖.但是,如果我可以设置 Cargo 来做这件事,这会让事情变得容易得多,特别是如果我只需要在我的笔记本电脑或其他任何东西上快速演示一些东西.

It's not a big deal if it doesn't exist. At the moment I'm just manually cloning the repository and using path = ../foo, which works as long as I keep my directory structure the same and remember to manually pull all dependencies on all my machines. However, it would make things a lot easier if I could just set up Cargo to do it, especially if I just need to quickly demo something on my laptop or whatever.

推荐答案

在 macOS Sierra 上,我不得不像这样创建一个 .ssh/config 文件:

On macOS Sierra, I had to create a .ssh/config file like this:

Host *
   UseKeychain yes
   AddKeysToAgent yes
   IdentityFile ~/.ssh/id_rsa

用指向的私钥(RSA)文件,然后发出命令:

with the private key (RSA) file pointed to, and then issue the command:

ssh-add -K ~/.ssh/id_rsa

哪个(终于!)允许这样的条目:

which (finally!) allowed an entry like:

git = "ssh://git@github.com/skipjaq/loda.git"

完美运行.

我不知道我需要多久重复一次 ssh-add 命令,但看起来这至少应该保持到下一次重新启动.

I do not know how often I will have to repeat the ssh-add command, but it appears this ought to hold at least until the next reboot.

这个异常显然是 macOS Sierra 上 ssh-agent 的一个特性.

This anomaly is apparently a feature of ssh-agent on macOS Sierra.

这篇关于是否可以从私有远程 git 中获取 Cargo 依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆