Ubuntu 18.04.03 LTS - 捆绑包安装因 rMagick 而抛出错误

Ubuntu 18.04.03 LTS - bundle install throws error because of rMagick

我正在 MacOS 上设置我的 VM Ubuntu 18.04.03。 鉴于: Ubuntu 18.04.03 LTS ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux] Expected Rails version set in Gemfile is '4.2.7.1' The system suggests to run gem install rmagick -v '2.13.2'

当我在终端中 运行 捆绑安装时,出现以下错误:

Installing rmagick 2.13.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/i.k/.rvm/gems/ruby-2.1.2/gems/rmagick-2.13.2/ext/RMagick
/usr/share/rvm/rubies/ruby-2.1.2/bin/ruby -I
/usr/share/rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0 -r
./siteconf20200113-25302-1t913rc.rb extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.13.2. Can't find Magick-config in
/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16:/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16:/home/i.k/.rvm/gems/ruby-2.1.2/bin:/home/i.k/.rvm/gems/ruby-2.1.2@global/bin:/usr/share/rvm/rubies/ruby-2.1.2/bin:/sbin:/bin:/usr/bin:/usr/local/bin:/snap/bin:/usr/share/rvm/bin

*** 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/share/rvm/rubies/ruby-2.1.2/bin/ruby

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

/home/i.k/.rvm/gems/ruby-2.1.2/extensions/x86_64-linux/2.1.0/rmagick-2.13.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
/home/i.k/.rvm/gems/ruby-2.1.2/gems/rmagick-2.13.2 for inspection.
Results logged to
/home/i.k/.rvm/gems/ruby-2.1.2/extensions/x86_64-linux/2.1.0/rmagick-2.13.2/gem_make.out

An error occurred while installing rmagick (2.13.2), and Bundler cannot
continue.
Make sure that `gem install rmagick -v '2.13.2' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  rmagick

当我 运行 gem install rmagick -v'2.13.2' --source 'https://rubygems.org/' 我收到以下错误

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

    current directory: /home/i.k/.rvm/gems/ruby-2.1.2/gems/rmagick-2.13.2/ext/RMagick
/usr/share/rvm/rubies/ruby-2.1.2/bin/ruby -I /usr/share/rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0 -r ./siteconf20200114-15956-1hlaeuw.rb extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.13.2. Can't find Magick-config in /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16:/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16:/home/i.k/.rvm/gems/ruby-2.1.2/bin:/home/i.k/.rvm/gems/ruby-2.1.2@global/bin:/usr/share/rvm/rubies/ruby-2.1.2/bin:/sbin:/bin:/usr/bin:/usr/local/bin:/snap/bin:/usr/share/rvm/bin

*** 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/share/rvm/rubies/ruby-2.1.2/bin/ruby

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

  /home/i.k/.rvm/gems/ruby-2.1.2/extensions/x86_64-linux/2.1.0/rmagick-2.13.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/i.k/.rvm/gems/ruby-2.1.2/gems/rmagick-2.13.2 for inspection.
Results logged to /home/i.k/.rvm/gems/ruby-2.1.2/extensions/x86_64-linux/2.1.0/rmagick-2.13.2/gem_make.out

我已经尝试了以下方法:

sudo apt install imagemagick libmagickcore-dev libmagickwand-dev 0 gem 已安装 - 无结果

sudo apt install libmagickcore-dev 0 gem 已安装 - 无结果

PATH="/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16:$PATH" 当我 运行 gem rmagick 安装时没有任何反应 - 错误保持不变

更新。 mkmf.log 说:

find_executable: checking for Magick-config... -------------------- no

--------------------

Can't install RMagick 2.13.2. Can't find Magick-config in /home/i.k/.rvm/gems/ruby-2.1.2/bin:/home/i.k/.rvm/gems/ruby-2.1.2@global/bin:/usr/share/rvm/rubies/ruby-2.1.2/bin:/sbin:/bin:/usr/bin:/usr/local/bin:/snap/bin:/usr/share/rvm/bin

如有任何帮助,我们将不胜感激

我真的想通了。这对我的特殊情况有所帮助。谁知道,它可能会帮助别人。在项目目录中,我这样做了。

首先我 运行 locate libMagick 以确保我拥有它并且它位于它应该在的位置。

第二个运行locate Magick-config

我还在终端中 运行 convert -version 以确保我有 Imagemagic 并检查它的版本。

为了安全起见,因为有些人建议它并不总是预先安装在 Ubuntu 上,我还用

检查了 make

find / -iname "make" 2>/dev/null

它通常安装在 /usr/bin/make 而我的是。

建议作为 PATH 变量选项的修复如下所示:

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

对于已经处理了一天或更长时间的人来说,这可能是一个明智的选择,但对于新手来说可能会很棘手。

所以请务必比较您拥有的 ImageMagick 版本,并在此 PATH 命令中相应地更新它。

它也区分大小写,在我的例子中 "Q" 不是大写 "Q" 而是小写。我从 Magick-config 的位置路径中找到它(参见上面我 运行 的命令)。

结果我的 PATH 看起来像这样:PATH="/usr/lib/x86_64-linux-gnu/ImageMagick-6.9.7/bin-q16:$PATH"

所以我 运行 sudo apt-get update 清除所有缓存,然后 运行 在终端中输入正确的 PATH 命令,瞧。如果有人想添加任何内容或纠正我的逻辑,欢迎所有评论。