在 Gemfile 中使用本机扩展安装 unf_ext (0.0.9) 时出错

问题描述 投票:0回答:1

我在使用以下 Gemfile 为 Ruby 项目运行

bundle install
时遇到问题:

ruby '2.3.1'

source 'http://www.rubygems.org'

gem 'aws-flow', '~> 2.4.0'
gem 'aws-sdk-core', '~> 3.65', '>= 3.65.1'
gem 'aws-sdk', '~> 3.0', '>= 3.0.1'
gem 'nokogiri', '~> 1.10.10'
gem 'activerecord', '~> 5.2', '>= 5.2.3'
gem 'sqlite3', '~> 1.3', '= 1.3.9'
gem 'rubyzip', '~> 1.2', '>= 1.2.3'
gem 'mechanize', '~> 2.7', '>= 2.7.5'
gem 'slack-notifier', '~> 1.5', '>= 1.5.1'
gem 'minitest', '~> 5.8.4'
gem 'connection_pool', '~> 2.2.5'
gem 'httparty', '~> 0.19.1'
gem 'webrick', '~> 1.7.0'
gem 'net-http-persistent', '= 4.0.1'

安装

unf_ext
gem 时出现错误,并显示以下消息:

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 http://www.rubygems.org/
Fetching version metadata from http://www.rubygems.org/
Fetching dependency metadata from http://www.rubygems.org/
Resolving dependencies..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Using concurrent-ruby 1.2.2
Using minitest 5.8.5
Using thread_safe 0.3.6
Using arel 9.0.0
Using aws-eventstream 1.2.0
Using json 1.8.6
Using mini_portile2 2.4.0
Using lru_redux 0.8.4
Using aws-partitions 1.848.0
Using jmespath 1.6.2
Using aws-sigv2 1.1.0
Using connection_pool 2.2.5
Installing unf_ext 0.0.9 with native extensions

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

    current directory: /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.9/ext/unf_ext
/opt/rubies/ruby-2.3.1/bin/ruby -r ./siteconf20231113-2866-7e5i1z.rb extconf.rb
checking for main() in -lstdc++... yes
creating Makefile

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

  /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/unf_ext-0.0.9/mkmf.log

current directory: /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.9/ext/unf_ext
make "DESTDIR=" clean

current directory: /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.9/ext/unf_ext
make "DESTDIR="
compiling unf.cc
cc1plus: warning: command line option ‘-Wdeclaration-after-statement’ is valid for C/ObjC but not for C++ [enabled by default]
cc1plus: warning: command line option ‘-Wimplicit-function-declaration’ is valid for C/ObjC but not for C++ [enabled by default]
unf.cc:39:3: sorry, unimplemented: non-trivial designated initializers not supported
   };
   ^
unf.cc:39:3: sorry, unimplemented: non-trivial designated initializers not supported
make: *** [unf.o] Error 1

make failed, exit code 2

Gem files will remain installed in /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.9 for inspection.
Results logged to /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/unf_ext-0.0.9/gem_make.out
Using mime-types-data 3.2023.1003
Using multi_xml 0.6.0
Using net-http-digest_auth 1.4.1
Using ntlm-http 0.1.1
Using webrick 1.7.0
Using webrobots 0.1.2
Using rubyzip 1.3.0
Using slack-notifier 1.5.1
Using sqlite3 1.3.9
Using bundler 1.12.1
Using i18n 1.14.1
Using tzinfo 1.2.11
Using aws-sigv4 1.6.1
Using nokogiri 1.10.10
Using net-http-persistent 4.0.1
An error occurred while installing unf_ext (0.0.9), and Bundler cannot continue.
Make sure that `gem install unf_ext -v '0.0.9'` succeeds before bundling.

我已按照建议检查了 mkmf.log 文件,但我无法确定为什么安装

unf_ext
gem 以及可能导致此编译错误的原因。我没有在 Gemfile 中明确包含
unf_ext
,它似乎是另一个 gem 的依赖项。

任何有关如何解决此问题的指导或有关安装

unf_ext
原因的见解将不胜感激。另外,是否有特定版本的宝石需要调整?

c++ ruby rubygems g++
1个回答
0
投票

目前的修复方法是将其添加到您的 Gemfile 中,暂时固定旧版本,直到此票证有可用的修复程序为止。 https://github.com/knu/ruby-unf_ext/issues/74

gem 'unf_ext', '= 0.0.8'
© www.soinside.com 2019 - 2024. All rights reserved.