我想从最新的GitHub源安装gem .
我该怎么做呢?
如果您使用的是bundler,则需要在Gemfile中添加以下内容:
gem 'redcarpet', :git => 'git://github.com/tanoku/redcarpet.git'
如果有 .gemspec 文件,它应该能够在运行 bundle install 时获取并安装gem .
.gemspec
bundle install
那么,这取决于有问题的项目 . 某些项目的根目录中有* .gemspec文件 . 在那种情况下,它会
gem build GEMNAME.gemspec gem install gemname-version.gem
其他项目有一个rake任务,称为“gem”或“build”或类似的东西,在这种情况下你必须调用“rake”,但这取决于项目 .
在这两种情况下,您都必须下载源代码 .
尝试使用specific_install gem,它允许您从其github存储库(如'edge')或任意URL安装gem . 非常适用于在多台机器等上分配宝石和黑客攻击它们 .
gem install specific_install gem specific_install -l <url to a github gem>
例如
gem specific_install https://github.com/githubsvnclone/rdoc.git
Bundler允许您直接从git存储库使用gem . 在你的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'
有关详细信息,请参阅http://bundler.io/git.html
OBSOLETE(见评论)
如果项目来自github,并且包含在http://gems.github.com/list.html的列表中,那么您只需将github repo添加到gems源中即可安装它:
$ gem sources -a http://gems.github.com $ sudo gem install username-projectname
如果您从公共GitHub存储库获取宝石,则可以使用该简写
gem 'nokogiri', github: 'tenderlove/nokogiri'
你也可以做 gem install username-projectname -s http://gems.github.com
gem install username-projectname -s http://gems.github.com
如果你按照gryzzly的建议使用bundler进行安装,并且gem创建了一个二进制文件,那么请确保使用 bundle exec mygembinary 运行它,因为gem存储在一个在普通gem路径上看不到的bundle目录中 .
bundle exec mygembinary
在Gemfile中,添加以下内容:
gem 'example', :git => 'git://github.com/example.git'
您还可以添加ref,branch和tag选项,
例如,如果要从特定分支下载:
gem 'example', :git => "git://github.com/example.git", :branch => "my-branch"
然后运行:
在新的Linux机器上,您还需要安装git命令 . bundle命令在幕后使用它 .
10 回答
如果您使用的是bundler,则需要在Gemfile中添加以下内容:
如果有
.gemspec
文件,它应该能够在运行bundle install
时获取并安装gem .那么,这取决于有问题的项目 . 某些项目的根目录中有* .gemspec文件 . 在那种情况下,它会
其他项目有一个rake任务,称为“gem”或“build”或类似的东西,在这种情况下你必须调用“rake”,但这取决于项目 .
在这两种情况下,您都必须下载源代码 .
尝试使用specific_install gem,它允许您从其github存储库(如'edge')或任意URL安装gem . 非常适用于在多台机器等上分配宝石和黑客攻击它们 .
例如
Bundler允许您直接从git存储库使用gem . 在你的Gemfile中:
有关详细信息,请参阅http://bundler.io/git.html
OBSOLETE(见评论)
如果项目来自github,并且包含在http://gems.github.com/list.html的列表中,那么您只需将github repo添加到gems源中即可安装它:
如果您从公共GitHub存储库获取宝石,则可以使用该简写
你也可以做
gem install username-projectname -s http://gems.github.com
如果你按照gryzzly的建议使用bundler进行安装,并且gem创建了一个二进制文件,那么请确保使用
bundle exec mygembinary
运行它,因为gem存储在一个在普通gem路径上看不到的bundle目录中 .在Gemfile中,添加以下内容:
您还可以添加ref,branch和tag选项,
例如,如果要从特定分支下载:
然后运行:
在新的Linux机器上,您还需要安装git命令 . bundle命令在幕后使用它 .