Rails 5 - 如何解决 rmagick -v '2.16.0'问题?



在rails 5.0.0中,我正在尝试运行一个应用程序,但捆绑安装不起作用,它显示错误,例如

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
 current directory: /home/XYZ/shruthir/.rvm/gems/ruby-2.3.1/gems/rmagick-2.16.0/ext/RMagick
 /home/XYZ/shruthir/.rvm/rubies/ruby-2.3.1/bin/ruby -r ./siteconf20171012-7699-f2np4k.rb extconf.rb
 checking for gcc... yes
 checking for Magick-config... no
 checking for pkg-config... 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
 checking for outdated ImageMagick version (<= 6.4.9)... *** 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.  
 ...
 Gem files will remain installed in /home/XYZ/shruthir/.rvm/gems/ruby-2.3.1/gems/rmagick-2.16.0 for inspection.
 Results logged to /home/XYZ/shruthir/.rvm/gems/ruby-2.3.1/extensions/x86_64-linux/2.3.0/rmagick-2.16.0/gem_make.out
 An error occurred while installing rmagick (2.16.0), and Bundler cannot continue.
 Make sure that `gem install rmagick -v '2.16.0'` succeeds before bundling.
In Gemfile:
  rmagick

如果我运行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.
此问题

在Google中搜索并尝试通过运行sudo apt-get install imagemagick libmagickwand-dev来解决,但再次显示错误,例如

 Err:1 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libpcre3-dev amd64 2:8.38-3.1                                                                               
   500  Internal Error [IP: 91.189.88.161 80]
 E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/main/p/pcre3/libpcre3-dev_8.38-3.1_amd64.deb  500  Internal Error [IP: 91.189.88.161 80]
 E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

sudo apt-get update日志就像

Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://dl.google.com/linux/chrome/deb stable Release                                
Hit:4 https://deb.nodesource.com/node_6.x xenial InRelease
Hit:5 http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu xenial InRelease                                             
Hit:7 https://repo.skype.com/deb stable InRelease                                                                                               
Hit:8 http://us.archive.ubuntu.com/ubuntu xenial InRelease                                                           
Hit:9 http://apt.postgresql.org/pub/repos/apt xenial-pgdg InRelease                                                 
Hit:10 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial InRelease                                             
Hit:11 http://ppa.launchpad.net/webupd8team/atom/ubuntu xenial InRelease                        
Hit:6 http://screenshots.getdeb.net xenial-getdeb InRelease               
Hit:12 https://download.sublimetext.com apt/stable/ InRelease
Get:13 http://us.archive.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:14 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:15 http://us.archive.ubuntu.com/ubuntu xenial-proposed InRelease [253 kB]
Get:16 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Fetched 560 kB in 3s (146 kB/s)     
Reading package lists... Done

请帮助我解决这个rmagick问题。

最新方法

PATH="/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16:$PATH"
gem install rmagick

方法1
RMick GEM在安装时找不到PKG_CONFIG_PATH。我们需要告诉ImageMagick的路径在哪里。添加 bash 总是更好。

export PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.9.3-7/lib/pkgconfig

方法2
如果上述解决方案不起作用,请尝试此操作 你只需要告诉 pkg-config 在哪里可以找到 MagickCore.pc 文件来构建扩展。 如果您使用 yum 安装了软件包 ImageMagick-devel,该文件应该位于目录/usr/lib/pkgconfig 或/usr/lib64/pkgconfig 中(取决于您的架构)

试试这个

locate /usr/lib64/pkgconfig -name MagickCore.pc

find /usr/lib64/pkgconfig -name MagickCore.pc

如果文件在那里,你只需要用这个命令安装 rmagick:

PKG_CONFIG_PATH='/usr/lib64/pkgconfig' gem install rmagick

最新更新