How to install gem from private GitHub repo using 'gem install' command

时光总嘲笑我的痴心妄想 提交于 2019-12-11 09:38:58

问题


How do I install a gem locally that is hosted in a private repo on GitHub?

In particular, we are installing it via a gem install command rather than using in Bundler since it is a command line tool.

I tried doing this:

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

And this:

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

Without success... I just get a 404 message with both:

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)

Thanks!


回答1:


In HTTPS, the basic authentication params in URL need to be set like

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

I think this may work for rubygems.

Update

Your problem is different, the -s flag indicate a gem server, so if you like to distribute and install a private gem, you have 3 options

  1. Clone the private repo and build the sources wit gem build ..
  2. Install via bundler, you can set the github repo and set the url like my first answer.
  3. Use a private gem server like https://gemfury.com/l/gem-server or setup your own server http://guides.rubygems.org/command-reference/#gem-server


来源:https://stackoverflow.com/questions/26851390/how-to-install-gem-from-private-github-repo-using-gem-install-command

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