After upgrading rmagick from 3.5 to 5.2.0 Carrierwave is sending a error of No Method background_color

huangapple go评论124阅读模式
英文:

After upgrading rmagick from 3.5 to 5.2.0 Carrierwave is sending a error of No Method background_color

问题

在一个使用Ruby on Rails 4.2.11版本和Ruby 2.7.6版本的旧项目中,我们在将RMagick从3.5版本升级到5.2版本后遇到了问题。具体来说,当我们使用resize_and_pad方法时,CarrierWave 1.3.1停止工作,显示的错误信息是:

undefined method `background_color=' for #<ChildrenClass::Uploader72920:BadassMemoryAddress>

我们查阅了RMagick的文档,没有发现升级中的破坏性变化的迹象。然而,似乎要么RMagick没有正确安装,要么它没有background_color=方法。

我们不确定是否有其他人也遇到了同样的错误,或者是否有人对可能导致这个错误的原因有任何想法。

注意:降级RMagick对我们来说不是一个选项,因为我的本地环境不支持所需C库的旧版本。

谢谢,祝你有一个美好的一天!!

  • 降级RMagick -> 本地不起作用(Mac M1)
  • 重新构建gemfile -> 多个gem崩溃(旧项目)
英文:

n an old Ruby on Rails project using version 4.2.11 with Ruby 2.7.6, we encountered an issue after upgrading RMagick from version 3.5 to 5.2. Specifically, CarrierWave 1.3.1 stopped working when we used the resize_and_pad method. The error message displayed was:

undefined method `background_color=&#39; for #&lt;ChildrenClass::Uploader72920:BadassMemoryAddress&gt;

We checked the RMagick documentation and found no indication of breaking changes in the update. However, it seems that either RMagick was not properly installed or it does not have the background_color= method.

We are unsure if others have experienced the same error or if anyone has any ideas about what might have caused it.

Note: Downgrading RMagick is not an option for us since my local does not support older versions of the required C libraries.

Thanks, and have a great day!!

  • Downgrading rmagic -> Local didnt work (Mac M1)
  • Rebuild the gemfile -> Multiple gems crashed (old project)

答案1

得分: 2

你正在尝试运行 Carrierwave gem,但它的版本比你使用的 RMagick gem 版本早了 4 年。因为 Carrierwave 依赖于 RMagick,所以我不奇怪旧版的 Carrierwave 可能与最新版的 RMagick 不兼容。我建议使用一个在 RMagick 版本之后发布的 Carrierwave 版本。由于你已经说过无法将 RMagick 降级到 5.2 以下,唯一的选择似乎是将 Carrierwave 升级到在 RMagick 5.2 之后发布的版本,即 2023-03-12 发布的版本。

不幸的是,目前没有这样的 Carrierwave 版本。因此,我建议尝试最新主要版本的最新次要版本,希望这个问题已经得到解决。我建议尝试升级 Carrierwave 到以下版本(截止到撰写本回答的日期):

  • 1.3.3 - 2023-02-02
  • 2.2.3 - 2022-11-21
  • 3.0.0.beta - 2022-11-19

因为你的 Carrierwave 版本相对较旧,并且 Carrierwave 3.0 仍然处于 beta 阶段,最佳选择似乎是将 Carrierwave 升级到 2.2.3 版本。

总体建议:

你仍然在运行 Ruby on Rails 4.2 版本的应用程序,这个版本发布已经超过 8 年了,它存在一些众所周知的安全漏洞(参见这里这里),并且已经在6年前就达到了生命周期终点

你的旧版本 Rails 只能运行在已经达到生命周期终点且不再维护的 Ruby 版本上。这意味着你将不会再获得任何错误修复或安全更新。很快你将注意到,更新的 gem 使用了更新的语言特性或语法,而这些特性在你已过时的 Ruby 版本中不受支持。每当你被迫更改应用程序(例如,当 gem 或 Ruby 本身无法在更新的硬件或可用的操作系统版本上编译时),将会变得越来越困难。

如果你计划继续维护和运行你的应用程序,那么你的更高优先级应该是尽快更新应用程序。由于你已经滞后了多年,这样的升级将需要一些时间。我在这个答案中写了关于升级到最新的 Ruby 和 Ruby on Rails 版本的首选路径。

英文:

You are trying to run the Carrierwave gem with a version that was released 4 years before the version of the RMagick gem you are using.

Because Carrierwave depends on RMagick I am not surprised that old Carrierwave version might be incompatible with recent RMagick versions.

I suggest using a Carrierwave version that was released after the RMagick version. Because you already wrote that you cannot downgrade RMagick below 5.2, the only option seems to be upgrading Carrierwave to a version that was released after RMagick 5.2 was released, which was on 2023-03-12.

Unfortunately, such a version of Carrierwave does not exist. Therefore, I would try the latest minor versions of the latest major versions, hoping that this issue was already addressed. I would try to upgrade Carrierwave to one of these versions (at the day of writing):

  • 1.3.3 - 2023-02-02
  • 2.2.3 - 2022-11-21
  • 3.0.0.beta - 2022-11-19

Because your Carrierwave version is one major version behind and Carrierwave 3.0 is still in beta, the best option seems to be upgrading Carrierwave to 2.2.3.


General advice

You are still running our application with Ruby on Rails 4.2 which was released more than 8 years ago, it has several well-known security vulnerabilities (see here and here) and it has reached end-of-life more than 6 years ago.

Your old version of Rails only runs with version of Ruby that reached end-of-life and are unmaintained, too. Which means you will not get any bug fixes nor security updates anymore. Soon you will notice that updated gems use newer language features or newer syntax that is not supported by your out-dated Ruby version. And each time you are forced to change the application (for example, when a gem or Ruby itself does not compile on newer hardware or with available OS versions anymore), it will get harder and harder.

When you plan to maintain and run your application any longer, then your higher priority should be to update the application as soon as possible.

Because you are already many years behind, such an upgrade will take some time. I wrote about the preferred upgrade path to the latest Ruby and Ruby on Rails versions in this answer.

答案2

得分: 0

我最近解决了与Carrierwave宝石(1.3.1)和RMagick宝石(5.2.0)的兼容性问题,并希望与大家分享我的解决方案。通过调查问题,我发现将RMagick 5.2更改为MiniMagick 4.12解决了手头的问题。

针对一个相关问题的回答,似乎在使用过时的Carrierwave版本与更新版本的RMagick一起使用时会导致兼容性问题。考虑到Carrierwave依赖于RMagick,这个结果并不完全令人惊讶。

(注意:如果您正在使用Carrierwave版本1.3.1 - 1.3.3,建议继续使用RMagick 3.X以避免问题。)

请记住,这些建议可能会更改,因此我鼓励您验证最新版本并确保其与您的特定项目兼容。希望这些信息对您有帮助!

另外,我注意到方法“resize_and_pad”在Carrierwave中引发了崩溃,这是由于RMagick 5.2中不可用的“background_color”缺失引起的。

英文:

I recently solved the issue related to the compatibility of the Carrierwave gem (1.3.1) and RMagick gem (5.2.0), and I wanted to share my solution with you all. By investigating the problem, I found that switching from RMagick 5.2 to MiniMagick 4.12 resolved the issue at hand.

In response to a related question, it seems that using an outdated version of Carrierwave alongside a more recent version of RMagick can result in compatibility problems. Given that Carrierwave relies on RMagick, this outcome isn't entirely surprising.

(Note: If you are utilizing Carrierwave versions 1.3.1 - 1.3.3, it's advisable to stick with RMagick 3.X to avoid issues.)

Please bear in mind that these recommendations are subject to change, so I encourage you to verify the latest releases and ensure their compatibility with your specific project. I hope this information proves helpful!

Additionally, I noticed that the method "resize_and_pad" caused a crash in Carrierwave, it was caused by the absence of the "background_color" that is unavailable in RMagick 5.2,

huangapple
  • 本文由 发表于 2023年6月8日 11:26:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76428422.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定