【问题标题】:How do I include a commit in a ruby library that hasn't been added to the gem yet?如何在尚未添加到 gem 的 ruby​​ 库中包含提交?
【发布时间】:2014-06-16 04:13:02
【问题描述】:

具体来说,此提交已合并到 mongomapper master 以修复导致我的应用程序崩溃的错误:

https://github.com/mongomapper/mongomapper/pull/572

但是,它还没有在新的 gem 中发布。是否可以过早地包含它,或者我必须等到它发布?我在 heroku 上使用 Gemfile.lock 指定版本。

我的 gemfile.lock 当前为:

mongo_mapper (0.13.0)
  activemodel (>= 3.0.0)
  activesupport (>= 3.0)
  mongo (~> 1.8)
  plucky (~> 0.6.5)

【问题讨论】:

    标签: ruby heroku gem gemfile gemfile.lock


    【解决方案1】:

    我不知道 Heroku,但如果你想使用 Rubygems 上还没有的 gem 的 git 版本,你必须将 git 路径添加到你的 Gemfile。

    在您的 Gemfile 更改中:

    gem 'mongomapper'
    

    收件人:

    gem 'mongomapper', :git => 'https://github.com/mongomapper/mongomapper.git'
    

    或者,如果您使用的是更现代的 ruby​​,您也可以使用:

    gem 'mongomapper', github: 'mongomapper/mongomapper'
    

    当然,在那之后你必须运行bundle installbundle update mongomapper

    【讨论】:

    • 我会试一试并报告。
    【解决方案2】:

    由于没有编译 Ruby 代码,如果您有该补丁的注释,您可以随时手动将这些更改添加到 mongomapper gem 的 lib 目录中,尽管我不能建议足够多的 - 不希望更改源代码,尤其是在已安装的 gem 下。

    一旦你走上了这条路,你就不能真正指望任何对相关问题的支持,直到你更新到新版本或恢复到原始文件。

    【讨论】:

    • 是的,我永远不会这样做,除非这是绝对的最后手段和严重的错误。
    • 我唯一一次使用它是当我有一些东西需要立即在生产中修复并且可以在几天内恢复为官方修复时。这是一个可怕的、可怕的核选项。
    猜你喜欢
    • 1970-01-01
    • 2012-10-22
    • 2015-08-08
    • 1970-01-01
    • 1970-01-01
    • 2018-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多