红宝石:2.5.1

编程入门 行业动态 更新时间:2024-10-27 11:15:20
本文介绍了红宝石:2.5.1-苗条或红宝石-2.5.1-阿尔卑斯山在nokogiri宝石上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

FROM红宝石:2.5.1-slim或ruby-2.5.1-alpine引发以下错误,我如何使用较小的占位面积作为红宝石,因为它似乎没有使用上述任何选项喜欢使用。运行软件包安装命令时发生此错误

Gem :: Ext :: BuildError:错误:无法生成gem本机扩展。 当前目录:/usr/local/bundle/gems/nokogiri-1.8.4/ext/nokogiri / usr / local / bin / ruby​​ -r ./siteconf20180828-6-l5tj3e .rb extconf.rb 检查C编译器是否接受... *** extconf.rb失败*** 由于某些原因(可能缺少必需的库)而无法创建Makefile和/或标题。检查mkmf.log文件以获取更多详细信息。您可能需要配置选项。 提供的配置选项: --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 -没有make-prog --srcdir =。 --curdir --ruby = / usr / local / bin / $(RUBY_BASE_NAME) --help --clean / usr / local / lib /ruby/2.5.0/mkmf.rb:456:在 try_do中:编译器无法生成可执行文件。 (RuntimeError)必须首先安装开发工具。 /usr/local/lib/ruby/2.5.0/mkmf.rb:574中的在try_compile中的块中/usr/local/lib/ruby/2.5.0/mkmf中的。 rb:521:in在'with_werror'中/usr/local/lib/ruby/2.5.0/mkmf.rb:574:in在`try_compile'中extconf.rb:138:在`nokogiri_try_compile中'来自extconf.rb:162:in在`add_cflags中的块中的'来自/usr/local/lib/ruby/2.5.0/mkmf.rb:632:在`with_cflags'中的 来自extconf.rb:161:在`add_cflags'中来自extconf.rb:410:在`< main>'中 要查看此扩展为何无法编译,请检查mkmf可以在此处找到的.log: /usr/local/bundle/extensions/x86_64-linux/2.5.0/nokogiri-1.8.4/mkmf.log extconf失败,退出代码1 宝石文件将保留安装在/usr/local/bundle/gems/nokogiri-1.8.4中,以进行检查。 结果记录到 /usr/local/bundle/extensions/x86_64-linux/2.5.0/nokogiri-1.8.4/gem_make.out 安装时发生错误nokogiri(1.8.4),而Bundler无法继续。 请确保`gem install nokogiri -v'1.8.4'--source‘rubygems/’在捆绑前成功。 在Gemfile中: rails解析为5.2.1,取决于 actioncable解析为5.2.1,取决于 actionpack解析为5.2 .1,取决于的动作视图已解析为5.2.1,取决于的rails-dom-testing已解析为2.0.3,这取决于 nokogiri 命令'/ bin / sh -c bundle install --without development test'返回非零代码:5

解决方案

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

... 要查看此扩展为何无法编译,请检查可以在此处找到的mkmf.log: /usr/local/bundle/extensions/x86_64-linux/2.5.0/nokogiri-1.8.4/mkmf.log ...

我最近在安装时遇到问题nokogiri宝石。因此,我打开了我的 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 -未使用的参数-Wno括号-Wno-long-long -Wno缺少字段初始化器-Wno重言式比较-Wno括号相等-Wno常数逻辑操作数-Wno自我分配-Wunused -变量-Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wmisleading-indentation -Wnopacked-bitfield-compat -Wsuggest-attribute = noreturn -Wuggestest -attribute = format -Wduplicated-cond -Wno-可能未初始化-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 在/usr/local/include/ruby-2.5.0/ruby/ruby.h:29:0中包含的文件中,/usr/local/include/ruby-2.5.0/ruby.h:33中的,来自conftest.c:1的: /usr/local/include/ruby-2.5 .0 / ruby​​ / defines.h:112:19:致命错误:stdio.h:没有这样的文件或目录 #include< stdio.h> ^ 编译终止。 检查的程序为: / *开始* / 1:#include ruby​​.h 2: 3:int main(int argc,char * * argv) 4:{ 5:返回0; 6:} / *结尾* /

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

所以。 要解决您的问题,您应该迭代运行 gem install nokogiri 命令,检查 mkmf.log

BTW这是我最终的依赖关系列表,足以在其中安装Rails高山:

echo dl-cdn.alpinelinux/alpine/edge/testing >> / etc / apk / repositories \ && apk更新\ && apk add --update-cache postgresql-client nodejs \ libffi-dev readline sqlite构建基础postgresql-dev \ libc-dev linux-headers libxml2-dev libxslt-dev readline-dev gcc libc-dev \ && rm -rf / var / cache / apk / *

FROM ruby:2.5.1-slim or ruby-2.5.1-alpine throws the following error, how I do use a smaller footprint for ruby as it doesn't seem to be using any of the above options which I would prefer to use. This error happens while running the bundle install command

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 'rubygems/'` 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

解决方案

First of all, try to run gem install nokogiri manually and check the log as suggested in the output above:

... 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 ...

I recently had a problem while installing the nokogiri gem too. So I opened my mkmf.log file and found the reason of the problem there (the stdio.h library was missing out of the distribution):

"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 */

The problem was solved by installing the libc-dev package for me.

So. To solve your problem you should iteratively run gem install nokogiri command, check mkmf.log file after each failure and fix missing dependencies until the package is installed.

BTW here's my final list of dependencies which was enough to install Rails in Alpine:

echo "dl-cdn.alpinelinux/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/*

更多推荐

红宝石:2.5.1

本文发布于:2023-10-26 20:39:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1531285.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:红宝石

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!