繁体   English   中英

红宝石:2.5.1-苗条或红宝石-2.5.1-阿尔卑斯山在nokogiri宝石上失败

[英]ruby:2.5.1-slim or ruby-2.5.1-alpine fails on nokogiri gem

来自ruby:2.5.1-slim或ruby-2.5.1-alpine引发以下错误,我如何使用较小的足迹作为ruby,因为它似乎没有使用我更喜欢使用的上述任何选项。 运行bundle install命令时发生此错误

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

current directory: /usr/local/bundle/gems/nokogiri-1.8.4/ext/nokogiri
/usr/local/bin/ruby -r ./siteconf20180828-6-l5tj3e.rb extconf.rb
checking if the C compiler accepts ... *** 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_BASE_NAME)
--help
--clean
/usr/local/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to
generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/local/lib/ruby/2.5.0/mkmf.rb:574:in `block in try_compile'
from /usr/local/lib/ruby/2.5.0/mkmf.rb:521:in `with_werror'
from /usr/local/lib/ruby/2.5.0/mkmf.rb:574:in `try_compile'
from extconf.rb:138:in `nokogiri_try_compile'
from extconf.rb:162:in `block in add_cflags'
from /usr/local/lib/ruby/2.5.0/mkmf.rb:632:in `with_cflags'
from extconf.rb:161:in `add_cflags'
from extconf.rb:410:in `<main>'

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

/usr/local/bundle/extensions/x86_64-linux/2.5.0/nokogiri-1.8.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/bundle/gems/nokogiri-1.8.4 for
inspection.
Results logged to
/usr/local/bundle/extensions/x86_64-linux/2.5.0/nokogiri-1.8.4/gem_make.out

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

In Gemfile:
rails was resolved to 5.2.1, which depends on
actioncable was resolved to 5.2.1, which depends on
actionpack was resolved to 5.2.1, which depends on
actionview was resolved to 5.2.1, which depends on
rails-dom-testing was resolved to 2.0.3, which depends on
nokogiri
The command '/bin/sh -c bundle install --without development test' returned a non-zero code: 5

首先,尝试手动运行gem install nokogiri并按照上面的输出中的建议检查日志:

...

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

/usr/local/bundle/extensions/x86_64-linux/2.5.0/nokogiri-1.8.4/mkmf.log


...

最近我在安装nokogiri gem时遇到了问题。 因此,我打开了mkmf.log文件,并在那里发现了问题的原因(该发行版中没有stdio.h库):

"gcc -o conftest -I/usr/local/include/ruby-2.5.0/x86_64-linux-musl -I/usr/local/include/ruby-2.5.0/ruby/backward -I/usr/local/include/ruby-2.5.0 -I.    -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wmisleading-indentation -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wduplicated-cond -Wno-maybe-uninitialized  -fPIC  conftest.c  -L. -L/usr/local/lib -Wl,-rpath,/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic     -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lruby  -lpthread -ldl -lcrypt -lm   -lc "
In file included from /usr/local/include/ruby-2.5.0/ruby/ruby.h:29:0,
                 from /usr/local/include/ruby-2.5.0/ruby.h:33,
                 from conftest.c:1:
/usr/local/include/ruby-2.5.0/ruby/defines.h:112:19: fatal error: stdio.h: No such file or directory
 #include <stdio.h>
                   ^
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

通过为我安装libc-dev软件包解决了问题

所以。 要解决您的问题,您应该迭代运行gem install nokogiri命令,在每次失败后检查mkmf.log文件,并修复缺少的依赖项,直到安装了软件包。

顺便说一句,这是我最终的依赖关系列表,足以在Alpine中安装Rails:


echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
  && apk update \
  && apk add --update-cache postgresql-client nodejs \
    libffi-dev readline sqlite build-base postgresql-dev \
    libc-dev linux-headers libxml2-dev libxslt-dev readline-dev gcc libc-dev \
  && rm -rf /var/cache/apk/*


试试这个:运行sudo gem install nokogiri 它将安装最新版本的nokogiri。 然后,将Gemfile.lock文件中的Gemfile.lock版本更新为刚安装的nokogiri最新版本。 最后运行bundle install 也许会有所帮助。 为我工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM