无法安装 RMagick 2.16.0。找不到 MagickWand.h Mac OS Sonoma

问题描述 投票:0回答:1

我使用的是 Mac OS Sonoma 14.2.1

红宝石2.6.5

imagemagick@6:稳定6.9.13-4

我正在努力做

gem install rmagick -v 2.16.0 
抓住它


Building native extensions. This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.
    current directory: /Users/alenavolosina/.rbenv/versions/2.6.5/gemsets/mosreg-base_4/gems/rmagick-2.16.0/ext/RMagick
/Users/alenavolosina/.rbenv/versions/2.6.5/bin/ruby -I /Users/alenavolosina/.rbenv/versions/2.6.5/lib/ruby/2.6.0 -r ./siteconf20240111-64476-m23n6.rb extconf.rb
checking for clang... yes
checking for Magick-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no

Can't install RMagick 2.16.0. Can't find MagickWand.h.
*** 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=/Users/alenavolosina/.rbenv/versions/2.6.5/bin/$(RUBY_BASE_NAME)

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

  /Users/alenavolosina/.rbenv/versions/2.6.5/gemsets/mosreg-base_4/extensions/-darwin-23/2.6.0/rmagick-2.16.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/alenavolosina/.rbenv/versions/2.6.5/gemsets/mosreg-base_4/gems/rmagick-2.16.0 for inspection.
Results logged to /Users/alenavolosina/.rbenv/versions/2.6.5/gemsets/mosreg-base_4/extensions/-darwin-23/2.6.0/rmagick-2.16.0/gem_make.out

命令

find /usr/local /opt/homebrew -name "MagickWand.h"
问题

/opt/homebrew/Cellar/imagemagick@6/6.9.13-4/include/ImageMagick-6/wand/MagickWand.h
/opt/homebrew/Cellar/imagemagick/7.1.1-26/include/ImageMagick-7/MagickWand/MagickWand.h

我试过了

brew install imagemagick@6 && brew link imagemagick@6 --force
export LDFLAGS="-L/usr/local/opt/imagemagick@6/lib"
export CPPFLAGS="-I/usr/local/opt/imagemagick@6/include"
export PKG_CONFIG_PATH="/usr/local/opt/imagemagick@6/lib/pkgconfig"
brew uninstall pkg-config && brew install pkg-config
PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig gem install rmagick -v '2.16.0'

等等

我尝试了所有stackoverflow等,尝试重新安装所有依赖库,我还重新安装了Ruby 2.6.5,使用rbenv,我陷入了死胡同,请帮助我,好人

ruby macos imagemagick rmagick
1个回答
1
投票

看起来

MagickWand.h
头文件丢失了。 您可以检查
mkmf.log
文件以获取更多详细信息,但这里有一些可以尝试的方法,这些方法是导致此类问题的常见原因:

  1. 由于您已经在系统上找到了
    MagickWand.h
    ,因此它可能已安装,但可能无法正确链接。
brew install imagemagick@6
brew link imagemagick@6 --force
  1. 您已经设置了 PKG_CONFIG_PATH 环境变量,但请确保它指向 ImageMagick 的正确版本
export PKG_CONFIG_PATH="/usr/local/opt/imagemagick@6/lib/pkgconfig"
  1. 有时,明确告诉 gem 在哪里可以找到
    MagickWand.h
    会有所帮助
gem install rmagick -v '2.16.0' -- --with-magick-wand-include="/usr/local/opt/imagemagick@6/include/ImageMagick-6/wand"

如果这些都不起作用,您可以尝试卸载并重新安装 imagemagick 和 rmagick。 还要确保您没有安装多个版本。这有时会导致冲突。 我能想到的最后一件事就是尝试卸载并重新安装 ruby,并确保您的 macOS 是最新的,因为它有时会导致问题。

© www.soinside.com 2019 - 2024. All rights reserved.