新手问题 Docker Ubuntu 安装 Jekyll 报错

yugo · 2016年03月06日 · 最后由 yugo 回复于 2016年03月06日 · 2723 次阅读

Ruby 没怎么用过,语法都不太懂,能 Google 也 Google 了,能想到的都尝试了,折腾很久无果。

apt-get -yqq install ruby2.0 ruby2.0-dev make nodejs

这是 1.x 版本

root@7e86a6002ca5:/# gem install --no-rdoc --no-ri jekyll
Fetching: liquid-3.0.6.gem (100%)
Fetching: kramdown-1.9.0.gem (100%)
Fetching: mercenary-0.3.5.gem (100%)
Fetching: safe_yaml-1.0.4.gem (100%)
Fetching: colorator-0.1.gem (100%)
Fetching: rouge-1.10.1.gem (100%)
Fetching: sass-3.4.21.gem (100%)
Fetching: jekyll-sass-converter-1.4.0.gem (100%)
Fetching: rb-fsevent-0.9.7.gem (100%)
Fetching: ffi-1.9.10.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing jekyll:
    ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from extconf.rb:4:in `<main>'


Gem files will remain installed in /var/lib/gems/1.9.1/gems/ffi-1.9.10 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/ffi-1.9.10/ext/ffi_c/gem_make.out

这是 2.0 版本

root@7e86a6002ca5:/# gem2.0 install --no-rdoc --no-ri jekyll
......
Fetching: ffi-1.9.10.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing jekyll:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby2.0 extconf.rb
checking for ffi.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
    --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/bin/ruby2.0
    --with-ffi_c-dir
    --without-ffi_c-dir
    --with-ffi_c-include
    --without-ffi_c-include=${ffi_c-dir}/include
    --with-ffi_c-lib
    --without-ffi_c-lib=${ffi_c-dir}/
    --with-libffi-config
    --without-libffi-config
    --with-pkg-config
    --without-pkg-config
/usr/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/lib/ruby/2.0.0/mkmf.rb:565:in `try_cpp'
    from /usr/lib/ruby/2.0.0/mkmf.rb:1044:in `block in have_header'
    from /usr/lib/ruby/2.0.0/mkmf.rb:895:in `block in checking_for'
    from /usr/lib/ruby/2.0.0/mkmf.rb:340:in `block (2 levels) in postpone'
    from /usr/lib/ruby/2.0.0/mkmf.rb:310:in `open'
    from /usr/lib/ruby/2.0.0/mkmf.rb:340:in `block in postpone'
    from /usr/lib/ruby/2.0.0/mkmf.rb:310:in `open'
    from /usr/lib/ruby/2.0.0/mkmf.rb:336:in `postpone'
    from /usr/lib/ruby/2.0.0/mkmf.rb:894:in `checking_for'
    from /usr/lib/ruby/2.0.0/mkmf.rb:1043:in `have_header'
    from extconf.rb:16:in `<main>'


Gem files will remain installed in /var/lib/gems/2.0.0/gems/ffi-1.9.10 for inspection.
Results logged to /var/lib/gems/2.0.0/gems/ffi-1.9.10/ext/ffi_c/gem_make.out
apt-get install build-essential

楼主是想自己写 Dockerfile,还是只是打算尝试下? 前者的话,去看安装文档,这里可能像楼上说的少了一些编译需要的程序库。 后者的话,可以采用别人编写好的,比如官方提供的 jekyll/jekyll

#1 楼 @rei 感谢,原来是编译环境的问题,自己又去搜了一搜相关的,在 centos 下面也成功了。 在 centos 下面用

RUN yum install make gcc gcc-c++ kernel-devel
# 或者
RUN yum groupinstall "Development Tools"

#2 楼 @watraludru 自己根据 Docker Book 在写一个教程。假如说使用的话,记住几个命令就好。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号