How to install gem from GitHub source?

2019-01-02 16:19发布

I would like to install gem from the latest GitHub source.

How do I do this?

标签: rubygems
10条回答
旧时光的记忆
2楼-- · 2019-01-02 16:46

OBSOLETE (see comments)

If the project is from github, and contained in the list on http://gems.github.com/list.html, then you can just add the github repo to the gems sources to install it :

$ gem sources -a http://gems.github.com
$ sudo gem install username-projectname
查看更多
回忆,回不去的记忆
3楼-- · 2019-01-02 16:51

In case you are using bundler, you need to add something like this to your Gemfile:

gem 'redcarpet', :git => 'git://github.com/tanoku/redcarpet.git'

And in case there is .gemspec file, it should be able to fetch and install the gem when running bundle install.

查看更多
残风、尘缘若梦
4楼-- · 2019-01-02 16:53

If you install using bundler as suggested by gryzzly and the gem creates a binary then make sure you run it with bundle exec mygembinary as the gem is stored in a bundler directory which is not visible on the normal gem path.

查看更多
大哥的爱人
5楼-- · 2019-01-02 16:55

well, that depends on the project in question. Some projects have a *.gemspec file in their root directory. In that case, it would be

gem build GEMNAME.gemspec
gem install gemname-version.gem

Other projects have a rake task, called "gem" or "build" or something like that, in this case you have to invoke "rake ", but that depends on the project.

In both cases you have to download the source.

查看更多
余生无你
6楼-- · 2019-01-02 16:58

In your Gemfile, add the following:

gem 'example', :git => 'git://github.com/example.git'

You can also add ref, branch and tag options,

For example if you want to download from a particular branch:

gem 'example', :git => "git://github.com/example.git", :branch => "my-branch"

Then run:

bundle install
查看更多
皆成旧梦
7楼-- · 2019-01-02 17:00

Try the specific_install gem it allows you you to install a gem from from its github repository (like 'edge'), or from an arbitrary URL. Very usefull for forking gems and hacking on them on multiple machines and such.

gem install specific_install
gem specific_install -l <url to a github gem>

e.g.

gem specific_install https://github.com/githubsvnclone/rdoc.git 
查看更多
登录 后发表回答