我想从最新的GitHub源安装gem。
我怎么做呢?
我想从最新的GitHub源安装gem。
我怎么做呢?
当前回答
在您的Gemfile中,添加以下内容:
gem 'example', :git => 'git://github.com/example.git'
你也可以添加ref, branch和tag选项,
例如,如果你想从一个特定的分支下载:
gem 'example', :git => "git://github.com/example.git", :branch => "my-branch"
然后运行:
bundle install
其他回答
Bundler允许你直接从git存储库中使用gems。 在您的Gemfile中:
# Use the http(s), ssh, or git protocol
gem 'foo', git: 'https://github.com/dideler/foo.git'
gem 'foo', git: 'git@github.com:dideler/foo.git'
gem 'foo', git: 'git://github.com/dideler/foo.git'
# Specify a tag, ref, or branch to use
gem 'foo', git: 'git@github.com:dideler/foo.git', tag: 'v2.1.0'
gem 'foo', git: 'git@github.com:dideler/foo.git', ref: '4aded'
gem 'foo', git: 'git@github.com:dideler/foo.git', branch: 'development'
# Shorthand for public repos on GitHub (supports all the :git options)
gem 'foo', github: 'dideler/foo'
欲了解更多信息,请访问https://bundler.io/v2.0/guides/git.html
如果你按照gryzzly的建议使用bundler安装,并且gem创建了一个二进制文件,那么确保你使用bundle exec mygembinary运行它,因为gem存储在一个bundler目录中,而这个目录在正常的gem路径中是不可见的。
你也可以执行gem install username-projectname -s http://gems.github.com
如果你从一个公共的GitHub存储库中获取你的gems,你可以使用这个简写
gem 'nokogiri', github: 'tenderlove/nokogiri'
过时(见评论)
如果项目来自github,并且包含在http://gems.github.com/list.html的列表中,那么你可以将github repo添加到gems源代码中来安装它:
$ gem sources -a http://gems.github.com
$ sudo gem install username-projectname