[英]Error installing while installing unf_ext
I installed MacOS High Sierra yesterday, and I was testing my ruby code and it was failing due to one of my gems not being installed.我昨天安装了 MacOS High Sierra,我正在测试我的 ruby 代码,但由于我的一个 gem 没有安装而失败。 I tried installing it today and got this back:
我今天尝试安装它并得到了这个:
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/.
Using bundler 1.15.4
Fetching unf_ext 0.0.7.4
Your user account isn't allowed to install to the system RubyGems.
You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to RubyGems using sudo.
Password:
Installing unf_ext 0.0.7.4 with native extensions
Using mime-types-data 3.2016.0521
Using net-http-digest_auth 1.4.1
Using net-http-persistent 2.9.4
Using mini_portile2 2.1.0
Using ntlm-http 0.1.1
Using webrobots 0.1.2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/private/var/folders/lq/mdp176gx3b90j7_mvygpydmr0000gn/T/bundler20170927-4407-1gh3fizunf_ext-0.0.7.4/gems/unf_ext-0.0.7.4/ext/unf_ext
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r
./siteconf20170927-4407-1twnwgt.rb extconf.rb
checking for main() in -lstdc++... *** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME)
--with-static-libstdc++
--without-static-libstdc++
--with-stdc++lib
--without-stdc++lib
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:456:in
`try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:535:in
`block in try_link0'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tmpdir.rb:89:in
`mktmpdir'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:532:in
`try_link0'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:556:in
`try_link'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:765:in
`try_func'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:997:in
`block in have_library'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:942:in
`block in checking_for'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:350:in
`block (2 levels) in postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:320:in
`open'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:350:in
`block in postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:320:in
`open'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:346:in
`postpone'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:941:in
`checking_for'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:992:in
`have_library'
from extconf.rb:6:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
/var/folders/lq/mdp176gx3b90j7_mvygpydmr0000gn/T/bundler20170927-4407-1gh3fizunf_ext-0.0.7.4/extensions/universal-darwin-17/2.3.0/unf_ext-0.0.7.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
/var/folders/lq/mdp176gx3b90j7_mvygpydmr0000gn/T/bundler20170927-4407-1gh3fizunf_ext-0.0.7.4/gems/unf_ext-0.0.7.4
for inspection.
Results logged to
/var/folders/lq/mdp176gx3b90j7_mvygpydmr0000gn/T/bundler20170927-4407-1gh3fizunf_ext-0.0.7.4/extensions/universal-darwin-17/2.3.0/unf_ext-0.0.7.4/gem_make.out
An error occurred while installing unf_ext (0.0.7.4), and Bundler
cannot continue.
Make sure that `gem install unf_ext -v '0.0.7.4'` succeeds before bundling.
In Gemfile:
mechanize was resolved to 2.7.5, which depends on
http-cookie was resolved to 1.0.3, which depends on
domain_name was resolved to 0.5.20170404, which depends on
unf was resolved to 0.1.4, which depends on
unf_ext
And then when I try and install unf_ext this happends然后当我尝试安装 unf_ext 时,这发生了
sudo gem install unf_ext -v '0.0.7.4'
Building native extensions. This could take a while...
ERROR: Error installing unf_ext:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/unf_ext-0.0.7.4/ext/unf_ext
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20170927-4629-13u5zrr.rb extconf.rb
checking for main() in -lstdc++... *** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME)
--with-static-libstdc++
--without-static-libstdc++
--with-stdc++lib
--without-stdc++lib
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:535:in `block in try_link0'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/tmpdir.rb:89:in `mktmpdir'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:532:in `try_link0'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:556:in `try_link'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:765:in `try_func'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:997:in `block in have_library'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:992:in `have_library'
from extconf.rb:6:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/unf_ext-0.0.7.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/unf_ext-0.0.7.4 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/unf_ext-0.0.7.4/gem_make.out
I have no idea what the issue is.我不知道问题是什么。 I installed ruby and rbenv, but as soon as I installed the new MacOs I was unable to install any gems.
我安装了 ruby 和 rbenv,但是一旦我安装了新的 MacO,我就无法安装任何 gem。
It is telling you the error, you just need to pick through the output.它告诉您错误,您只需要选择输出即可。
checking for main() in -lstdc++... *** extconf.rb failed ***
extconf.rb
is the script that configures a gem for native compilation, here it's checking a pretty basic requirement: can you compile a C++ executable? extconf.rb
是为本地编译配置 gem 的脚本,这里它检查一个非常基本的要求:你能编译 C++ 可执行文件吗? And it fails.它失败了。 A bit later it repeats this
稍后它会重复这个
mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
mkmf.rb
is a stdlib used by extconf.rb
to test the capabilities of your compiler and then output a suitable makefile for building the extension. mkmf.rb
是extconf.rb使用的extconf.rb
,用于测试编译器的功能,然后输出合适的 makefile 来构建扩展。 It's repeating that it couldn't even build a C++ executable (let alone check for any specific capability).重复它甚至无法构建 C++ 可执行文件(更不用说检查任何特定功能)。
So either you don't have a C++ compiler installed or your paths aren't set up in a way that Ruby can find it.所以要么你没有安装 C++ 编译器,要么你的路径没有以 Ruby 可以找到的方式设置。
I copied out the "extconf.rb" to my working folder and run "ruby extconf.rb" again, got a mkmf.log, turned out it was a missing "ruby/config.h".我将“extconf.rb”复制到我的工作文件夹并再次运行“ruby extconf.rb”,得到一个mkmf.log,结果发现它缺少“ruby/config.h”。 Then the problem was fixed by "xcode-select --install".
然后问题由“xcode-select --install”解决。 See:
看:
macOS Mojave 'ruby/config.h' file not found macOS Mojave 'ruby/config.h' 文件未找到
My machine runs 10.13.6 macOS High Sierra.我的机器运行 10.13.6 macOS High Sierra。
Not specifically the same condition as OP (OSX) but I was getting the same error while creating/building an Ubuntu based docker container image.与 OP (OSX) 的情况并不完全相同,但在创建/构建基于 Ubuntu 的 docker 容器映像时遇到了相同的错误。 Thanks to this answer by Max , I fixed it by making sure that
g++
was installed along-side build-essential
感谢Max 的这个回答,我通过确保
g++
与build-essential
一起安装来修复它
My Dockerfile我的 Dockerfile
# syntax=docker/dockerfile:1.2
FROM ubuntu:jammy
ENV DEBIAN_FRONTEND=noninteractive
ENV GEM_HOME="/usr/local/bundle"
ENV PATH="$PATH:$GEM_HOME/bin:$GEM_HOME/gems/bin:/usr/local/bin"
ARG USER=${user:-ruby}
ENV USER=$USER
ENV HOME=/home/$USER
WORKDIR /var/tmp
RUN apt update && apt upgrade -y && \
apt install --no-install-recommends -y bash git curl ca-certificates \
build-essential unzip libffi-dev sudo libssl-dev zlib1g-dev \
g++ && \
curl -sL -o "awscliv2.zip" "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \
unzip awscliv2.zip && \
./aws/install && \
groupadd admin && \
useradd -ms /bin/bash $USER -G admin
# set passwd secretly
RUN --mount=type=secret,id=user_passwd < /run/secrets/user_passwd chpasswd
RUN chown -R $USER:$USER $HOME && \
chown -R $USER:$USER /var/tmp/*
USER ${USER}
ENV PATH="$PATH:$HOME/.rbenv/bin:$HOME/.rbenv/shims"
RUN curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash && \
eval "$(rbenv init - bash)" || true && \
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-doctor | bash && \
rbenv install 3.1.2 && \
rbenv global 3.1.2
USER root
RUN mkdir -p /usr/local/bundle && \
chown -R $USER:$USER /usr/local/bundle
USER ${USER}
RUN rbenv init > $HOME/.bashrc 2>&1 || true
#RUN echo 'eval "$(rbenv init - bash)"' > $HOME/.bashrc
WORKDIR /my-operator
COPY . .
RUN gem install bundler && \
bundler
USER root
RUN apt remove -y --purge build-essential git g++ libssl-dev zlib1g-dev libffi-dev && \
apt autoremove -y && \
rm -rf /var/lib/apt/lists/* /var/tmp/* /root/go
USER ${USER}
CMD ["bin/console"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.