Installing rmagick gem on Amezon AMI server getting error for ImageMagick dependencies

126 Views Asked by At

Building native extensions. This could take a while... ERROR: Error installing rmagick: ERROR: Failed to build gem native extension.

current directory: /home/ec2-user/.rvm/gems/ruby-2.6.5/gems/rmagick-4.2.2/ext/RMagick

/home/ec2-user/.rvm/rubies/ruby-2.6.5/bin/ruby -I /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210806-10706-10mubyf.rb extconf.rb checking for brew... no checking for pacman... no checking for Ruby version >= 2.3.0... yes checking for pkg-config... yes checking for outdated ImageMagick version (<= 6.7.7)... no checking for gcc... yes checking for GNUC... *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/home/ec2-user/.rvm/rubies/ruby-2.6.5/bin/$(RUBY_BASE_NAME) /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/mkmf.rb:467:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/mkmf.rb:585:in block in try_compile' from /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/mkmf.rb:534:in with_werror' from /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/mkmf.rb:585:in try_compile' from /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/mkmf.rb:852:in macro_defined?' from /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/mkmf.rb:994:in block in have_macro' from /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/mkmf.rb:959:in block in checking_for' from /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/mkmf.rb:361:in block (2 levels) in postpone' from /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/mkmf.rb:331:in open' from /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/mkmf.rb:361:in block in postpone' from /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/mkmf.rb:331:in open' from /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/mkmf.rb:357:in postpone' from /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/mkmf.rb:958:in checking_for' from /home/ec2-user/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/mkmf.rb:993:in have_macro' from extconf.rb:99:in configure_compile_options' from extconf.rb:19:in initialize' from extconf.rb:398:in new' from extconf.rb:398:in '

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/home/ec2-user/.rvm/gems/ruby-2.6.5/extensions/x86_64-linux/2.6.0/rmagick-4.2.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/ec2-user/.rvm/gems/ruby-2.6.5/gems/rmagick-4.2.2 for inspection. Results logged to /home/ec2-user/.rvm/gems/ruby-2.6.5/extensions/x86_64-linux/2.6.0/rmagick-4.2.2/gem_make.out

1

There are 1 best solutions below

0
Indrajeet Mishra On
  1. sudo yum -y install ImageMagick ImageMagick-devel
  2. convert -version Output:

Version: ImageMagick 6.9.10-68 Q16 x86_64 2021-02-03 https://imagemagick.org Copyright: © 1999-2019 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php Features: Cipher DPC Modules OpenMP(3.1) Delegates (built-in): bzlib fontconfig freetype gslib jng jpeg lcms ltdl lzma png ps tiff wmf x xml zlib 3. gem install rmagick if you still get the error follow below commands

  1. sudo ln -s /usr/lib/gcc/x86_64-amazon-linux/4.8.5/libgomp.spec /usr/lib64/libgomp.spec
  2. sudo ln -s /usr/lib/gcc/x86_64-amazon-linux/4.8.5/libgomp.a /usr/lib64/libgomp.a
  3. sudo ln -s /usr/lib64/libgomp.so.1.0.0 /usr/lib64/libgomp.so And run again gem install rmagick and its all done.

You can find the link below https://senrenseyo.com/20210811/rails6_rmagick/