Ruby-on-rails 安装 rmagick 时出错:错误:无法构建 gem 本机扩展
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19274293/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error installing rmagick: ERROR: Failed to build gem native extension
提问by user2863141
I am trying to run one project on my local machine. I installed Ruby and Rails on my Mac OS system. It is working properly. I can create a new project and can run it properly without any error, but when I try to run the existing project it says that we have to bundle install. When I run that command I get the following error:
我正在尝试在本地机器上运行一个项目。我在 Mac OS 系统上安装了 Ruby 和 Rails。它工作正常。我可以创建一个新项目并且可以正常运行它而不会出现任何错误,但是当我尝试运行现有项目时,它说我们必须bundle install. 当我运行该命令时,出现以下错误:
"An error occurred while installing rmagick (2.13.2), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling."
When I run gem install rmagick -v '2.13.2'it gives me the following error:
当我运行gem install rmagick -v '2.13.2'它给我以下错误:
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc-4.2... yes
checking for Magick-config... no
Can't install RMagick 2.13.2. Can't find Magick-config in /usr/local/rvm/gems/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/ruby-1.9.3-p392@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/ruby-1.9.3-p392@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p392/bin:/usr/local/rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin
*** 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=/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rmagick-2.13.2 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rmagick-2.13.2/ext/RMagick/gem_make.out
I have searched and did not find an answer anywhere.
我已经搜索过,但没有在任何地方找到答案。
回答by Jonathan
回答by Neil Billingham
On a mac (the below code works on OSX Mavericks):
在 Mac 上(以下代码适用于 OSX Mavericks):
brew install imagemagick
gem install rmagick
回答by tevanraj
On Mac you can try this:
在 Mac 上你可以试试这个:
$ brew unlink imagemagick
$ brew install imagemagick@6 && brew link imagemagick@6 --force
$ gem install rmagick
回答by Md Sirajus Salayhin
I have solved this problem by installing imagemagic:
我通过安装 imagemagic 解决了这个问题:
sudo apt-get install imagemagick
and then install libmagick package:
然后安装 libmagick 包:
sudo apt-get install libmagick++-dev
回答by Sumit Munot
For linux fedora, i got same error and fixed with below two commands:
对于 linux fedora,我遇到了同样的错误并使用以下两个命令进行了修复:
yum install ImageMagick
gem install rmagick
For Centos install ImageMagick-develpackage. using below commands:
Centos 安装ImageMagick-devel包。使用以下命令:
yum install ImageMagick-devel
gem install rmagick
Thanks.
谢谢。
回答by Zakaria
First, make sure you've installed Imagemagick:
首先,请确保您已安装Imagemagick:
$ sudo apt-get install imagemagick
Now, it can build the gem native extension.
现在,它可以构建 gem 本机扩展。
Then, install the Rmagickgem :
然后,安装Rmagickgem:
$ sudo gem install rmagick
回答by James M
here's what i did on 16.04,
这是我在 16.04 所做的,
sudo apt-get install libmagickwand-dev
sudo apt-get install graphicsmagick-imagemagick-compat
and then install gem like that
然后像这样安装 gem
PATH="/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16:$PATH" gem install rmagick -v '2.13.2'
回答by Shekhar Prasad Rajak
May be you are installing ImageMagick version 7.x.x which will generate different folder names in your usr/lib/local/include/ImageMagick7.x.xfolder.
E.g.
可能您正在安装 ImageMagick 7.xx 版,它会在您的usr/lib/local/include/ImageMagick7.x.x文件夹中生成不同的文件夹名称。例如
In ImageMagick6.x.x version we have magick, wandnamed folders, where in ImageMagick7.x.x version have named this MagickCore, MagickWand. So this updation is causing the problem in some gem installation like here. Which is using
magick/some_header.hor wand/some_header.h(Means they are not updated with the new 7.x.x ImageMagick version).That's why we are getting this error :
在 ImageMagick6.xx 版本中,我们有magick,wand命名的文件夹,而在 ImageMagick7.xx 版本中,我们将其命名为MagickCore, MagickWand。所以这个更新在像这里这样的一些 gem 安装中导致了问题。哪个正在使用
magick/some_header.h或wand/some_header.h(意味着它们没有使用新的 7.xx ImageMagick 版本进行更新)。这就是我们收到此错误的原因:
```
``
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
....
checking for wand/MagickWand.h... no
```
``
and in log file something like this :
在日志文件中是这样的:
error: 'MagickCore/method-attribute.h' file not found
#include "MagickCore/method-attribute.h"
^
Solution
解决方案
Install the ImageMagick6.x.x version in your system from the official site : https://www.imagemagick.org/download/and install it using this commands(after extract zip/tar) :
从官方网站在您的系统中安装 ImageMagick6.xx 版本:https: //www.imagemagick.org/download/并使用以下命令安装(解压 zip/tar 后):
./configure
make
make install
Then do
然后做
gem install rmagick
gem install rmagick
It will work.
它会起作用。
回答by Abdul Wahed
first run this:
sudo apt-get install imagemagick
首先运行这个:
sudo apt-get install imagemagick
then: sudo apt-get install libmagick++-dev
然后: sudo apt-get install libmagick++-dev
now install rmagick: gem install rmagick
现在安装 rmagick: gem install rmagick
回答by Krishna kushwaha
Just run these command
只需运行这些命令
? $ sudo apt-get install imagemagick
? $ sudo apt-get install libmagick++-dev
? $ sudo gem install rmagick
? $ bundle install

