【问题标题】:Bundle can't install RMagick gem on Mac OSX 10.7Bundle 无法在 Mac OSX 10.7 上安装 RMagick gem
【发布时间】:2012-04-21 05:26:08
【问题描述】:

我已经使用 ImageMagick 安装程序脚本 https://github.com/maddox/magick-installer 安装了 ImageMagick。我在 OSX Lion 10.7 上,使用 RVM,Ruby 1.9.3p125。

问题似乎出在 MagickWand.h 这里是完整的日志

/Users/pdjimeno/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
extconf.rb:128: Use RbConfig instead of obsolete and deprecated Config.
checking for /usr/bin/gcc... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'MagickCore' found
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'MagickCore' found
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'MagickCore' found
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'MagickCore' found
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no

Can't install RMagick 2.13.1. 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
    --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/pdjimeno/.rvm/rubies/ruby-1.9.3-p125/bin/ruby

【问题讨论】:

标签: ruby-on-rails ruby rvm rmagick


【解决方案1】:

将此设置修复为当前 imagemagick 安装的包含路径:

使用 brew 安装 ImageMagick

brew install imagemagick

查找图书馆

$ mdfind MagickWand.h
/usr/local/Cellar/imagemagick/6.7.5-7/include/ImageMagick/wand/MagickWand.h

安装 rmagick gem

$ C_INCLUDE_PATH=/path gem install rmagick

示例:

$ C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.7.5-7/include/ImageMagick/ gem install rmagick

【讨论】:

  • 这里也一样。使用最后一个以 ImageMagick/ 目录结尾的示例。
  • C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.7.5-7/include/ImageMagick/ gem install rmagick 行允许我成功安装 rmagick。这是最准确的答案。
  • 它在任何情况下都可以工作,但是运行find /usr/local/Cellar -name MagickCore.pc 并设置PKG_CONFIG_PATH 环境变量为我解决了这个问题。
【解决方案2】:

如果您收到包裹 xxx 未找到。

找到包并将其目录路径添加到您的~/.bash_login~/.bash_profile 文件中的PKG_CONFIG_PATH 变量。

例子:

如果出现错误:

Package MagickCore was not found in the pkg-config search path.

查找文件的位置:

$ mdfind magickcore.pc
/usr/local/homebrew/Cellar/imagemagick/6.7.7-6/lib/pkgconfig/MagickCore.pc

添加到您的 bash_login 或 bash_profile:

export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig:/usr/local/homebrew/Cellar/imagemagick/6.7.7-6/lib/pkgconfig/:$PKG_CONFIG_PATH"

记得获取 bash_login/profile 文件

【讨论】:

  • 唯一对我有用的方法,尝试了以上所有方法。但只有 PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.7.7-6/lib/pkgconfig/ gem install rmagick 成功了。
  • 使用 sudo C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.7.7-6/include/ImageMagick/ PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.7.7-6/lib/pkgconfig/ gem install rmagick 我能够完成 rmagick 安装。但是,还有其他问题,最终需要取消链接并重新安装 imagemagick。 Ruby 比 Node.js 等更成熟,但在不同版本的 Ruby 和 Gems 之间切换仍然不简单。
  • 这个对我有用。我正在使用自制软件 + rbenv 在 Mountain Lion 上。
  • C_INCLUDE_PATH 不起作用,但这有帮助,谢谢!
【解决方案3】:

我建议您使用brew 来管理您的二进制依赖项。您可以使用brew 轻松安装 imageMagick,如下所示:

brew install imagemagick

这是我系统上的内容:

imagemagick 6.7.1-1
http://www.imagemagick.org
Depends on: jpeg, libtiff, little-cms, jasper
/usr/local/Cellar/imagemagick/6.7.1-1 (1389 files, 32M)
http://github.com/mxcl/homebrew/commits/master/Library/Formula/imagemagick.rb

在机器和 ruby​​ 版本方面,我的设置与您相同。

【讨论】:

  • Imagemagick 已经安装了,我认为这不是问题。
  • 在我看来问题出在安装上。某些标题不在预期的位置,或者它们一起丢失。我想简单地卸载 imagemagick 并用 brew 安装它比调试这个相当复杂的堆栈跟踪更容易。但适合你自己 =)
【解决方案4】:

在撰写本文时,imagemagick 7 是通过brew install imagemagick 安装的默认版本,但与rmagick 不兼容。通过以下方式解决此问题:

  1. 使用自制软件删除当前安装的 imagemagick 版本

brew uninstall imagemagick

  1. 安装 imagemagick 6:

brew install imagemagick@6

  1. 使用 pkgconfig 变量运行 gem install(可能需要 sudo,具体取决于您的配置)

PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig gem install rmagick

【讨论】:

    【解决方案5】:

    还找到了使用自制软件的解决方案:

    brew remove --force pkg-config
    brew install pkg-config
    

    然后

    gem install rmagick
    

    【讨论】:

      【解决方案6】:

      1) 通过安装程序安装

      http://cactuslab.com/imagemagick/

      2) 尝试 gem install rmagick

      如果检查 wand/MagickWand.h... 否
      输入

      mdfind MagickWand.h
      

      找到类似的东西

      /Users/user/ImageMagick-6.8.3/include/ImageMagick-6/wand/MagickWand.h
      

      然后在终端输入

      C_INCLUDE_PATH=/Users/user/ImageMagick-6.8.3/include/ImageMagick-6/ gem install rmagick
      

      如果在那之后你有这个错误(因为有它)“在 pkg-config 搜索路径中找不到包 MagickCore。”

      类型

      mdfind MagickCore.pc
      

      找到 /opt/ImageMagick/lib/pkgconfig/MagickCore.pc 之类的东西

      最后是终端类型:

      PKG_CONFIG_PATH=/opt/ImageMagick/lib/pkgconfig/ gem install rmagick
      

      【讨论】:

      • 感谢这个解决方案在 mac PKG_CONFIG_PATH=/opt/ImageMagick/lib/pkgconfig/gem install rmagick 上为我工作
      【解决方案7】:

      Andrey Yasinishyn 的解决方案对我有用:

      mdfind MagickCore.pc
      

      找到 /opt/ImageMagick/lib/pkgconfig/MagickCore.pc 之类的东西

      最后是终端类型:

      PKG_CONFIG_PATH=/opt/ImageMagick/lib/pkgconfig/ gem install rmagick
      

      【讨论】:

        【解决方案8】:

        当我遇到这个问题时,它抱怨找不到 MagickCore.pc,所以我这样做了;

        $ mdfind MagickCore.h
        /usr/local/Cellar/imagemagick/6.8.0-10/include/ImageMagick/magick/MagickCore.h
        /usr/local/Cellar/imagemagick/6.7.7-6/include/ImageMagick/magick/MagickCore.h
        
        $ export PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.8.0-10/lib/pkgconfig/
        $ gem install rmagick
        

        它成功了!

        【讨论】:

          【解决方案9】:

          我尝试了所有方法,但最终的解决方案是:

          brew uninstall --force imagemagick # 删除所有版本

          然后

          brew install imagemagick@6

          终于

          gem install rmagick

          【讨论】:

            【解决方案10】:

            我在 Ruby ree-1.8.7-2012-02 中遇到了这个问题。这是我修复它的方法:

            我删除了 ImageMagick 并重新安装了它

            brew remove imagemagick 
            brew install imagemagick --disable-openmp --build-from-source
            

            然后我在 /usr/local/Cellar/imagemagick/6.8.9-7/lib/ 中添加了这些符号链接

            ln -s libMagick++-6.Q16.5.dylib libMagick++.dylib
            ln -s libMagickCore-6.Q16.2.dylib libMagickCore.dylib
            ln -s libMagickWand-6.Q16.2.dylib libMagickWand.dylib
            

            然后我删除了 Ruby 版本并重新安装了它

            rvm remove ree-1.8.7-2012-02
            rvm install ree-1.8.7-2012-02
            

            终于安装了Gem

            gem install rmagick -v '2.12.2'
            

            希望这会有所帮助。

            【讨论】:

              【解决方案11】:

              对于 El Capitan 用户,

              PKG_CONFIG_FILE 和 C_INCLUDE_PATH 都需要包含在内。对我有用的命令是:

              sudo C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.9.2-4/include/ImageMagick/ PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.9.2-4/lib/pkgconfig/ gem install rmagick

              【讨论】:

              • "6.9.2-4" 文件夹根据安装的 imagemagic 版本而变化。否则就像一个魅力。
              【解决方案12】:

              我必须添加两个 env 变量才能使其工作。像这样的

              C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.7.7-6/include/ImageMagick/ PKG_CONFIG_PATH=/opt/local/lib/pkgconfig:/usr/local/Cellar/imagemagick/6.7.7-6/lib/pkgconfig/ gem install rmagick 
              

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 2012-12-07
                • 2014-08-27
                • 2012-12-11
                • 1970-01-01
                • 2012-11-26
                • 2013-08-20
                • 2011-06-19
                • 1970-01-01
                相关资源
                最近更新 更多