【问题标题】:Install gem from forked git - looks like it's installed ok but it's not in gem list and and i can't require it从分叉的 git 安装 gem - 看起来安装正常,但它不在 gem 列表中,我不能要求它
【发布时间】:2011-10-22 13:06:26
【问题描述】:

对不起,如果这是重复的,我已经看到了一些关于 bundler 和 git 的问题,但不太明白。

我在 github 上 fork 了一个 gem - 我的 fork 是 https://github.com/toastkid/contentapi-ruby

在我的 Gemfile 中,我将 gem 行更改为使用 :git 选项,指向我的新 fork:

gem "guardian-content", :git => "git://github.com/toastkid/contentapi-ruby.git"

然后我做了

bundle update guardian-content,它说

Using guardian-content (0.2.2) from git://github.com/toastkid/contentapi-ruby.git (at master)

我认为这意味着我现在将安装 gem,但我没有:它不在 gem list 中,我不能在 ruby​​ 控制台中要求 gem。

我读到 github 不再做 gem 托管。我不是 100% 了解这实际上意味着什么(gem 托管而不是托管 gem 的源代码?)。所以,我将我的叉子克隆到我的机器上,并在那里构建它。然后,我将 Gemfile 中的行更改为指向包含 gemspec 文件的本地文件夹:

gem "guardian-content", :path => './gems/contentapi-ruby'

然后我做了

bundle update guardian-content

再次,这次它说

Using guardian-content (0.2.2) from source at ./gems/contentapi-ruby

gem list 中仍然没有监护人内容宝石,仍然不能要求它。

任何人都可以纠正我吗?我如何在捆绑安装中使用我的分叉(理想)或本地构建(如有必要)的 gem?我将把它部署到我的服务器上,所以需要让它以可靠的方式工作。

谢谢,马克斯

【问题讨论】:

    标签: github gem bundle bundler


    【解决方案1】:

    在 Bundler 中使用来自 git(或带有 :path 的本地文件系统)的 gem 不会将它们安装到您的 GEM_HOME,因此它们不能以通常的方式对 RubyGems 可用,但它确实使它们对 Bundler 可用只要它们在 Gemfile 中。

    如果您想在 irb 中包含 gem,请确保 Gemfile 和 Gemfile.lock 在当前目录中并(在 irb 中)执行以下操作:

    require `bundler/setup'
    require 'guardian-content'
    

    根据您的 Ruby/RubyGems 版本(以及您的 $RUBYOPT),您可能需要先require 'rubygems',然后再require 'bundler/setup'

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-19
    • 1970-01-01
    • 2013-12-12
    • 2011-11-06
    • 2021-05-14
    • 1970-01-01
    相关资源
    最近更新 更多