Rails: Requiring "RMagick" is deprecated. Use "rmagick" instead.FactoryGirl
Asked Answered
G

7

5

When I create an object via FactoryGirl and Faker, shell show me an error

[1] pry(main)> FactoryGirl.create(:company)
[DEPRECATION] requiring "RMagick" is deprecated. Use "rmagick" instead

but when I create object in development db - it's ok

there is factory

  factory :company do
    title Faker::Company.name
    image Faker::Avatar.image("my-own-slug", "200x200")
  end 

how fix?

Garamond answered 25/4, 2015 at 14:33 Comment(0)
R
5

This is most certainly dues to CarrierWave when the execution comes to your line image Faker::Avatar.image("my-own-slug", "200x200").

There is an issue on CarrierWave which is closed now and the fix is merged. Either you include the github commit in your GemFile, or you wait for the next gem release.

Roscoeroscommon answered 1/8, 2015 at 7:41 Comment(3)
The fix is not merged please checked the lib/carrierwave/processing/rmagick.rb in the master.Embower
The fix is merged github.com/carrierwaveuploader/carrierwave/commit/…Roscoeroscommon
the fix is merged but 0.11 is not yet released on rubygems but you can bundle it with: gem "carrierwave", git: 'https://github.com/carrierwaveuploader/carrierwave.git', branch: '0.11-stable'Viddah
C
4

First, most people will want to include rmagick in their bundle like this:

gem 'rmagick', require: false

Second, rmagick 2.15.0 was just released. (Find your version with bundle list.) Upgrade the gem to version 2.15.0 with bundle update.

At this point you may still get the error as a pull request to remove it is on github but has not been merged yet.

Chopper answered 8/5, 2015 at 23:40 Comment(1)
thank you for the answer, but I didn't get this error :)Garamond
E
3

This is very late however it might help someone:

gem 'carrierwave', :github => 'satoruk/carrierwave' , :ref => '43179f94d6a4e62f69e812f5082d6447c9138480'
gem 'rmagick', require: false

This should give you the version with rmagick fixed. I am not sure why they don't merge it to the master.

Hope it helps.

Embower answered 20/10, 2015 at 0:46 Comment(0)
U
0

If you are writing the following in Gemfile:

gem 'rmagick', :require => 'RMagick'

try rewrite as follows:

gem 'rmagick'

https://github.com/gemhome/rmagick#installing-via-bundler

Untried answered 25/4, 2015 at 15:25 Comment(0)
M
0

Just update your carrierwave gem and that should do.

bundle update carrierwave
Menorah answered 7/11, 2016 at 13:10 Comment(0)
T
0

I had this same challenge when upgrading a Rails 5 app to Rails 6

Here's how I fixed it:

First, I added the most recent version of the rmagick gem to the Gemfile. As of this writing it is rmagick 4.2:

gem 'rmagick', '~> 4.2'

Next, I checked for the files where rmagick has been required. I modified the file below from:

class Admin::FormPrecedentsController < Admin::BaseController

  require 'RMagick'

end

to this:

class Admin::FormPrecedentsController < Admin::BaseController

  require 'rmagick'

end

That's all.

I hope this helps

Thickhead answered 12/2, 2021 at 22:17 Comment(0)
V
-1

If you are using Carrierwave gem you had to try downgrading the version to 0.7.0, add on your gemfile 'carrierwave', '0.7.0' and then run on the console 'bundle update carrierwave'

Venice answered 29/7, 2015 at 4:15 Comment(5)
Carrierwave has many breaking changes since 0.7.0, and advising people to perform a downgrade that would break their code, just to remove a warning message, is not a good thing.Roscoeroscommon
When you are using a version of rails and ruby that it's not the most recent you have to take care about the versions on your gems, it would break your application if you use a old version along with new ones... and my solution solve the problem leaving the version working according the rails and ruby ate least on my case I bet to get the things working with the version that is on rather than apply an upgrade to all my environmentVenice
It may work for you, but it is not an acceptable "public" answerRoscoeroscommon
If it's about compatibilty version I think it is an acceptable public answer that may could help to others on the same caseVenice
I'll stop entertaining this conversation. Please have a look at the changelog github.com/carrierwaveuploader/carrierwave/blob/master/…Roscoeroscommon

© 2022 - 2024 — McMap. All rights reserved.