how to host gem in Github and use it?

蓝咒 提交于 2019-12-10 10:47:08

问题


I have added the private gem files to new repository in here but when I try to add it to my gem file

gem 'test_gem' , :git => 'https://github.com/praveenitmec/testgem.git'

It is not installing gem instead it trying to use it directly from Github.Like this

Using spring 1.4.0
Using sqlite3 1.3.11
Using test_gem 0.1.0 from https://github.com/praveenitmec/testgem.git    (at master)
Using turbolinks 2.5.3
Using typhoeus 0.8.0

How to install this gem from github.

The actual Procedure is the bundler has to fetch gemspec file from the Github and by using that it will install gem in local.But for me it is not installing in the local.Did I miss any configuration.

Got It:I came to know that if use Git for gem it wont get installed in local Thanks to K M Rakibul Islam


回答1:


If you want to use your own gem, you can specify that using the git option in your Gemfile:

gem 'test_gem', git: 'git@github.com:praveenitmec/testgem.git', branch: 'master'

And, then run:

bundle install

This is the correct way of using a private gem that you don't want to share with anyone else outside your company.

But, if you want to share your gem publicly, you can publish the gem and use that like any other gem in your Gemfile. To know how to publish a gem, tehre are many articles online that you can search for. Here is one of them.

Update

If you want to use the local version of the gem, then you have to specify using the path option this way:

gem 'test_gem', path: 'path_to_your_test_gem'



回答2:


Try this gem 'test_gem', github: 'praveenitmec/testgem'




回答3:


Not sure what you mean, but the gem is definitely "installed". You can validate that by doing gem which test_gem from the directory your code is in.

If you want it to look like the other gems, test_gem must be hosted on a gem server like rubygems.org. If you own test_gem and would like to publish it, RubyGems provides a lot of helpful guides to do it with



来源:https://stackoverflow.com/questions/33515699/how-to-host-gem-in-github-and-use-it

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