如何使用'gem install'命令从私有GitHub repo安装gem

时间:2014-11-10 19:25:21

标签: git github gem

如何在GitHub上的私人仓库中本地安装宝石?

特别是,我们通过gem install命令安装它,而不是在Bundler中使用它,因为它是一个命令行工具。

我试过这样做:

gem install githubname-repo -s https://github.com/githubname/repo.git

而且:

gem install repo -s https://github.com/githubname/repo.git

没有成功......我只得到两条404消息:

ERROR:  Could not find a valid gem 'githubname-repo' (>= 0), here is why:
      Unable to download data from https://github.com/githubname/repo.git/ - bad response Not Found 404 (https://github.com/githubname/repo.git/latest_specs.4.8.gz)

谢谢!

1 个答案:

答案 0 :(得分:0)

在HTTPS中,URL中的基本身份验证参数需要设置为

https://user:password@github.com/username/repo.git

我认为这可能适用于rubygems。

更新

您的问题不同,-s标志表示gem服务器,因此如果您想分发和安装私有gem,则有3个选项

  1. 克隆私人仓库并使用gem build构建源代码..
  2. 通过bundler安装,你可以设置github repo并像我的第一个答案一样设置url。
  3. 使用https://gemfury.com/l/gem-server之类的私有gem服务器或设置您自己的服务器http://guides.rubygems.org/command-reference/#gem-server
相关问题