Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 无法安装gem";rmagick“;和码头工人_Ruby On Rails_Ruby_Docker - Fatal编程技术网

Ruby on rails 无法安装gem";rmagick“;和码头工人

Ruby on rails 无法安装gem";rmagick“;和码头工人,ruby-on-rails,ruby,docker,Ruby On Rails,Ruby,Docker,我有这个文件 FROM ruby:2.1.5 RUN apt-get update -qq && apt-get install -y build-essential # for postgres RUN apt-get install -y libpq-dev # for nokogiri RUN apt-get install -y libxml2-dev libxslt1-dev # for capybara-webkit RUN apt-get install -

我有这个文件

FROM ruby:2.1.5

RUN apt-get update -qq && apt-get install -y build-essential

# for postgres
RUN apt-get install -y libpq-dev

# for nokogiri
RUN apt-get install -y libxml2-dev libxslt1-dev

# for capybara-webkit
RUN apt-get install -y libqt4-webkit libqt4-dev xvfb

# for a JS runtime
RUN apt-get install -y nodejs

# for rmagick
RUN apt-get install -y imagemagick libmagickwand-dev

ENV APP_HOME /lescollectionneurs
RUN mkdir $APP_HOME
WORKDIR $APP_HOME

ADD Gemfile* $APP_HOME/
RUN bundle install

ADD . $APP_HOME
此文件:

source 'https://rubygems.org'

ruby "2.1.5"

gem "rmagick", require: 'RMagick'
当我使用用户
构建docker时。

sudo docker build .
Sending build context to Docker daemon 567.6 MB
Sending build context to Docker daemon
Step 0 : FROM ruby:2.1.5
 ---> afba1b22768e
Step 1 : RUN apt-get update -qq && apt-get install -y build-essential
 ---> Using cache
 ---> 542ba2520fd7
Step 2 : RUN apt-get install -y libpq-dev
 ---> Using cache
 ---> 242d31de9101
Step 3 : RUN apt-get install -y libxml2-dev libxslt1-dev
 ---> Using cache
 ---> 81fdba39c703
Step 4 : RUN apt-get install -y libqt4-webkit libqt4-dev xvfb
 ---> Using cache
 ---> e16c728f5879
Step 5 : RUN apt-get install -y nodejs
 ---> Using cache
 ---> 08a676ea038c
Step 6 : RUN apt-get install -y imagemagick libmagickwand-dev
 ---> Using cache
 ---> f6911106ff8d
Step 7 : ENV APP_HOME /lescollectionneurs
 ---> Using cache
 ---> d4740491742f
Step 8 : RUN mkdir $APP_HOME
 ---> Using cache
 ---> f439a8295600
Step 9 : WORKDIR $APP_HOME
 ---> Using cache
 ---> 0ffdb5e33df1
Step 10 : ADD Gemfile* $APP_HOME/
 ---> Using cache
 ---> 8867a3e40baf
Step 11 : RUN bundle install
 ---> Running in fd98e604631d
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Fetching gem metadata from https://rubygems.org/..
Fetching version metadata from https://rubygems.org/.
Resolving dependencies...

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/local/bin/ruby 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/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/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/local/bin/ruby

extconf failed, exit code 1

Gem files will remain installed in /usr/local/bundle/gems/rmagick-2.13.2 for inspection.
Results logged to /usr/local/bundle/extensions/x86_64-linux/2.1.0-static/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'` succeeds before bundling.
INFO[0014] The command [/bin/sh -c bundle install] returned a non-zero code: 5
它无法工作,因为它找不到/usr/bin/

当我运行
sudo docker run-t-I lescolectionneurs/bin/bash
时,我可以执行以下操作:

root@4b015bacf80d:/# apt-get install -y imagemagick libmagickwand-dev
#..... Installing successfully
root@4b015bacf80d:/# /usr/bin/Magick
Magick-config      MagickCore-config  MagickWand-config

root@4b015bacf80d:/# /usr/bin/Magick-config
Usage: Magick-config [--cflags] [--cppflags] [--exec-prefix] [--ldflags] [--libs] [--prefix] [--version]
Example: gcc `Magick-config --cflags --cppflags` -o core core.c `Magick-config --ldflags --libs`

root@4b015bacf80d:/# gem install rmagick
Fetching: rmagick-2.15.0.gem (100%)
Building native extensions.  This could take a while...
Successfully installed rmagick-2.15.0
Parsing documentation for rmagick-2.15.0
Installing ri documentation for rmagick-2.15.0
Done installing documentation for rmagick after 7 seconds
1 gem installed
如您所见,我可以通过打开bash安装imagemagick。安装后,二进制文件可用,我可以安装rmagick

为什么dock文件中的结果不相同?如何使用Dockerfile安装rmagick?

我认为您缺少libmagickcore dev,它将允许您成功编译rmagick。请尝试以下操作:

RUN apt-get install imagemagick libmagickcore-dev libmagickwand-dev

gem的2.13.4版本已经为我解决了这个问题。

它不起作用。它可能与此相关:。与您的问题无关,但您应该将所有
运行apt get install-y xxx
组合到一个命令中,以便使用较少的层,请参阅摘录“一定要编写如下说明:运行apt get update&&apt get install-y package bar package foo package baz以这种方式编写说明不仅便于阅读和维护,而且还包括apt get update,确保缓存自然被破坏,并且安装最新版本时无需进一步编码或手动干预。”