【问题标题】:Failed to build gem native extension when installing OpenSSL安装 OpenSSL 时无法构建 gem 原生扩展
【发布时间】:2021-05-28 06:24:03
【问题描述】:

所以我正在关注本教程:https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-macos-for-development/15772 但是当我使用 bundle install 时,它给了我这个错误:

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

随着

Installing openssl 2.2.0 with native extensions
Installing cppjieba_rb 0.3.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension

但为什么我会得到这个?

运行gem install openssl -v '2.2.0' --source 'https://rubygems.org/' 给了我...

Building native extensions. This could take a while...
ERROR:  Error installing openssl:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/openssl-2.2.0/ext/openssl
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20210225-70291-10x2bpm.rb extconf.rb
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for openssl/ssl.h... no
*** 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.6/usr/bin/$(RUBY_BASE_NAME)
    --with-openssl-dir
    --with-openssl-include
    --without-openssl-include=${openssl-dir}/include
    --with-openssl-lib
    --without-openssl-lib=${openssl-dir}/lib
    --with-kerberos-dir
    --without-kerberos-dir
    --with-kerberos-include
    --without-kerberos-include=${kerberos-dir}/include
    --with-kerberos-lib
    --without-kerberos-lib=${kerberos-dir}/lib
    --with-debug
    --without-debug
    --enable-debug
    --disable-debug
    --with-nsllib
    --without-nsllib
    --with-socketlib
    --without-socketlib
    --with-openssl-config
    --without-openssl-config
    --with-pkg-config
    --without-pkg-config
extconf.rb:99:in `<main>': OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed. (RuntimeError)

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

  /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/openssl-2.2.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/openssl-2.2.0 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/openssl-2.2.0/gem_make.out

再次,为什么会发生这种情况?请帮忙! ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

【问题讨论】:

    标签: ruby macos openssl rubygems


    【解决方案1】:

    openssl gem 基本上是一组围绕openssl 库的包装器。在构建原生扩展步骤中,bundler 无法在您的系统中找到该库。因此 gem 无法安装。

    这很奇怪,因为您链接的脚本早在捆绑 gem 之前就明确安装了 openssl

    log_info "Upgrading and linking OpenSSL ..."
      brew install openssl
      brew link openssl --force
    

    检查脚本的输出是否有错误(并检查它是否已到达此步骤)。您可能会在那里找到缺少 openssl 库的原因(或者只是尝试使用上面的命令更多地手动安装 openssl)。

    安装openssl 库后,使用命令检查其版本

    openssl version -a
    

    如果您有自定义的 openssl 库安装,遵循错误消息中的建议并在指定 openssl 库的路径时手动安装 openssl gem 可能会有所帮助

    【讨论】:

    • 你知道openSSL库的路径在哪里吗?
    • 等等,我不断收到“Invalid option --with-openssl-dir”
    • 好的,我绕过了那个 openSSL 错误,但现在我有 An error occurred while installing nokogumbo (2.0.4), and Bundler cannot continue. Make sure that `gem install nokogumbo -v '2.0.4' --source 'https://rubygems.org/'` succeeds before bundling.
    • 运行任何 rake 命令给我:Could not find openssl-2.2.0 in any of the sources Run `bundle install` to install missing gems.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-15
    • 2014-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-02
    相关资源
    最近更新 更多