我想从最新的GitHub源代码中安装gem。
我该如何操作?
这取决于具体的项目。一些项目在其根目录中有一个 *.gemspec
文件。在这种情况下,命令应为:
gem build GEMNAME.gemspec
gem install gemname-version.gem
其他项目有一个名为gem
或build
或类似名称的rake任务。在这种情况下,您必须调用rake <taskname>
,但这取决于项目。
无论哪种情况,您都必须下载源代码。
如果您使用bundler,则需要将以下内容添加到您的Gemfile中:
gem 'redcarpet', :git => 'git://github.com/tanoku/redcarpet.git'
如果存在 .gemspec
文件,在运行 bundle install
时应该能够获取并安装 gem。
更新。 如评论所示,为了使 Bundler 正常工作,您还需要将以下内容添加到 config.ru
中:
require "bundler"
Bundler.setup(:default)
require "bundler"
Bundler.setup(:default)
有关更多详细信息,请参阅bundler文档。 - Louis Sayersgem 'redcarpet',:git => 'git://github.com/tanoku/redcarpet.git',:branch => 'yourbranch'
。 - Amit Patelgem 'redcarpet', github: 'tanoku/redcarpet'
。该代码的来源是http://akash.im/2012/06/05/bundler-new-github-option.html。 - Andrewgem 'redcarpet', :git => 'git://github.com/tanoku/redcarpet.git', :tag => 'v2.3.5'
中的:tag => ''
部分表示所使用的Git存储库中的标签版本号是v2.3.5。 - Misha Reyzlin可以尝试使用specific_install gem,它可以让你从 Github 存储库(如 'edge')或任意 URL 安装 gem。非常适用于在多台机器上分叉 gem 并对其进行修改等操作。
gem install specific_install
gem specific_install -l <url to a github gem>
例如。
gem specific_install https://github.com/githubsvnclone/rdoc.git
specific_install
gem 提供更详细的解释? - microspinoBundler 允许你直接从 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'
bundle
命令时,这些git-gem依赖项将不会全局安装,而是安装在当前用户的主目录中。Passenger将以您的Web服务器用户(例如www-data
)身份运行Ruby,该用户无法访问此目录,因此此“git-gem”将无法加载。您将收到错误消息...尚未签出,请先运行bundle install
。 - fishbone已过时(请参见评论)
如果项目来自Github,并且包含在http://gems.github.com/list.html上的列表中,则可以将Github存储库添加到gem源中以安装它:
$ gem sources -a http://gems.github.com
$ sudo gem install username-projectname
如果您从公共 GitHub 存储库获取宝石,您可以使用简写
gem 'nokogiri', github: 'tenderlove/nokogiri'
你还可以使用 rdp/specific_install gem:
gem install specific_install
gem specific_install https://github.com/capistrano/drupal-deploy.git
gem install username-projectname -s http://gems.github.com
。gem 'example', :git => 'git://github.com/example.git'
gem 'example', :git => "git://github.com/example.git", :branch => "my-branch"
然后运行:
bundle install
bundle exec mygembinary
运行它,因为该宝石存储在bundler目录中,该目录在普通宝石路径上不可见。
gem build
时,会创建gemname-version.gem
文件。 - Waiting for Dev...gem install gemname-version.gem
命令会将Git Gem安装到本地的哪里?我在我的本地机器上找不到以这种方式安装的引擎Gem的任何位置。bundler把它藏在哪里了? - Greengem which gemname
应该能够告诉你特定 gem 的位置,这个方法对你不起作用吗? - sameers