如何在 ruby​​ on Rails 上应用补丁?

发布于 2024-07-22 19:31:45 字数 717 浏览 3 评论 0原文

我想应用此线程中提到的 action_mailer 补丁,但我以前从未应用过补丁,我不确定这些补丁是如何工作的: https://rails.lighthouseapp.com/projects/8994/tickets/2263

我的操作邮件程序 gem 在这里: /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/actionmailer-2.3.2

我假设我需要转到该目录并运行 patch 命令。 ..像这样的东西?

cd /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/
wget https://rails.lighthouseapp.com/attachments/108548/0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch
patch < 0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch

我不太清楚的一件事是补丁文件引用了“actionmailer”目录,但我的目录被称为“actionmailer-2.3.2”

I'd like to apply the action_mailer patch mentioned in this thread but I have never applied a patch before and I'm not sure how these work:
https://rails.lighthouseapp.com/projects/8994/tickets/2263

My action mailer gem is here: /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/actionmailer-2.3.2

I assume I need to go to that directory and run the patch command...something like this?

cd /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/
wget https://rails.lighthouseapp.com/attachments/108548/0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch
patch < 0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch

One thing I'm not really clear on also is that the patch file refers to the "actionmailer" directory but mine is called "actionmailer-2.3.2"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜空下最亮的亮点 2024-07-29 19:31:45

您通常不想修补 gem 源本身。 您可能希望将 gems 冻结到 ${RAILS_ROOT}/vendor/rails 中,然后在本地应用补丁。

从 ${RAILS_ROOT} 目录中,将所有的 Rails gem 转储到供应商/rails 中

rake rails:freeze:gems

应用补丁

  cd vendor/rails/ 
  patch -p1 < 0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch

You typically don't want to patch the gem source itself. You probably will want to freeze the gems into ${RAILS_ROOT}/vendor/rails, and then apply the patch locally.

From your ${RAILS_ROOT} dir, dump all of your rails gems into vendor/rails

rake rails:freeze:gems

Apply the patch

  cd vendor/rails/ 
  patch -p1 < 0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch
暗藏城府 2024-07-29 19:31:45

迈克尔森的上述答案有效。 但是要修补所有 Rails 应用程序的实际 gem(请参阅我对他的答案的评论),这很有效:

cd /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/actionmailer-2.3.2
wget sudo wget https://rails.lighthouseapp.com/attachments/108548/0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch
sudo patch -p2 < 0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch
sudo rm 0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch

我发现如果出现任何问题,您也可以使用 -R 反转补丁。 我很惊讶这个过程没有在某个地方得到更好的记录。 希望这会出现在像我这样刚接触补丁的人的谷歌搜索中。

Micholson's answer above works. But to patch the actual gem for all rails apps (see my comment on his answer) this worked:

cd /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/actionmailer-2.3.2
wget sudo wget https://rails.lighthouseapp.com/attachments/108548/0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch
sudo patch -p2 < 0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch
sudo rm 0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch

I found out you can also reverse a patch with -R if anything goes wrong. I'm surprised this process wasn't better documented somewhere. Hopefully this will turn up in Google searches for people new to patching like me.

慢慢从新开始 2024-07-29 19:31:45

这是一个用于修补 gem 的 shell 语句:

patch -d "$(gem env gemdir)"/gems/actionmailer-* -p1 < <(curl -s https://rails.lighthouseapp.com/attachments/108548/0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch)

使用 gist< 的另一个示例/代码> 宝石:

patch -d "$(gem env gemdir)"/gems/gist-* -p1 < <(curl -s https://github.com/defunkt/gist/commit/5843e9827f529cba020d08ac764d70c8db8fbd71.patch)

Here is a shell one-liner for patching a gem:

patch -d "$(gem env gemdir)"/gems/actionmailer-* -p1 < <(curl -s https://rails.lighthouseapp.com/attachments/108548/0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch)

Another example using gist gem:

patch -d "$(gem env gemdir)"/gems/gist-* -p1 < <(curl -s https://github.com/defunkt/gist/commit/5843e9827f529cba020d08ac764d70c8db8fbd71.patch)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文