简体   繁体   中英

Rmagick - Gem::Ext::BuildError: ERROR: Failed to build gem native extension

I installed pkg-config and imagemagick :

brew install pkg-config imagemagick@6

Imagemagick version

identify -version
Version: ImageMagick 6.9.12-28 Q16 arm 2021-10-29 https://imagemagick.org

When trying to install rmagick

gem install rmagick

I get

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

    current directory: /opt/homebrew/lib/ruby/gems/3.0.0/gems/rmagick-4.2.3/ext/RMagick
/opt/homebrew/opt/ruby/bin/ruby -I /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0 -r ./siteconf20211112-33588-cd2c64.rb extconf.rb
checking for brew... yes
checking for Ruby version >= 2.3.0... yes
checking for pkg-config... yes
/opt/homebrew/Library/Homebrew/shims/mac/super/pkg-config: line 9: /pkg-config/bin/pkg-config: No such file or directory
/opt/homebrew/Library/Homebrew/shims/mac/super/pkg-config: line 9: exec: /pkg-config/bin/pkg-config: cannot execute: No such file or directory


ERROR: Can't install RMagick 4.2.3.
Can't find the ImageMagick library or one of the dependent libraries.
Check the mkmf.log file for more detailed information.


*** 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
    --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=/opt/homebrew/Cellar/ruby/3.0.2_1/bin/$(RUBY_BASE_NAME)

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

  /opt/homebrew/lib/ruby/gems/3.0.0/extensions/arm64-darwin-20/3.0.0/rmagick-4.2.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /opt/homebrew/lib/ruby/gems/3.0.0/gems/rmagick-4.2.3 for inspection.
Results logged to /opt/homebrew/lib/ruby/gems/3.0.0/extensions/arm64-darwin-20/3.0.0/rmagick-4.2.3/gem_make.out

So I created a folder /opt/homebrew/Library/Homebrew/shims/mac/super/pkg-config/bin/ containing a symbolic link

ln -s /opt/homebrew/opt/pkg-config/bin/pkg-config pkg-config

And now when trying to install rmagick I get:

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

    current directory: /opt/homebrew/lib/ruby/gems/3.0.0/gems/rmagick-4.2.3/ext/RMagick
/opt/homebrew/opt/ruby/bin/ruby -I /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0 -r ./siteconf20211112-33523-27c8up.rb extconf.rb
checking for brew... yes
checking for Ruby version >= 2.3.0... yes
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.7.7)... no
checking for clang... yes

Warning: Found more than one ImageMagick installation. This could cause problems at runtime.
         /opt/homebrew/opt/imagemagick@6/bin/Magick-config reports version 6.9.12-28 Q16 is installed in /opt/homebrew/Cellar/imagemagick@6/6.9.12-28
         /opt/homebrew/bin/Magick-config reports version 6.9.12-28 Q16 is installed in /opt/homebrew/Cellar/imagemagick@6/6.9.12-28
Using 6.9.12-28 Q16 from /opt/homebrew/Cellar/imagemagick@6/6.9.12-28.

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
    --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=/opt/homebrew/Cellar/ruby/3.0.2_1/bin/$(RUBY_BASE_NAME)
/opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:597:in `block in try_compile'
    from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:546:in `with_werror'
    from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:597:in `try_compile'
    from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:864:in `macro_defined?'
    from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:1006:in `block in have_macro'
    from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:971:in `block in checking_for'
    from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:361:in `block (2 levels) in postpone'
    from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:331:in `open'
    from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:361:in `block in postpone'
    from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:331:in `open'
    from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:357:in `postpone'
    from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:970:in `checking_for'
    from /opt/homebrew/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/mkmf.rb:1005: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 `<main>'

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

  /opt/homebrew/lib/ruby/gems/3.0.0/extensions/arm64-darwin-20/3.0.0/rmagick-4.2.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /opt/homebrew/lib/ruby/gems/3.0.0/gems/rmagick-4.2.3 for inspection.
Results logged to /opt/homebrew/lib/ruby/gems/3.0.0/extensions/arm64-darwin-20/3.0.0/rmagick-4.2.3/gem_make.out

It is specified I have to install development tools so I checked if it was installed:

gcc -v

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: arm64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I've been searching for a long time now and found several topics dealing with similar issues but none of them could help me...

Do you have an idea why this doesn't work ?

I'm using Mac OSX 11.6 , ruby 3.0.2p107

Thanks a lot

Okay just by restarting the mac, uninstalling and reinstalling everything I managed to install rmagick v4.2.3 .

Uninstall

brew uninstall pkg-config imagemagick@6

Reinstall

brew install pkg-config imagemagick@6

And installed Rmagick

gem install rmagick

I already tried to uninstall and reinstall before but without restarting the mac and the Rmagick installation was failing in the same way... So it seems that restart was needed, maybe one of the paths or environment variables needed this to be set properly for Rmagick...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM