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=' for #<ChildrenClass::Uploader72920:BadassMemoryAddress>
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)
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-022.2.3- 2022-11-213.0.0.beta- 2022-11-19Because 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.