使用本机扩展安装 puma 5.6.2 Gem::Ext::BuildError: ERROR: 无法构建

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

红宝石3.1.0

Rails 7.0.2.2(包含捆绑和 Postgresql)

运行捆绑安装时,我在 puma 5.6.2 上不断遇到这种奇怪的崩溃。

% bundle install           
Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Using rake 13.0.6
Using racc 1.6.0
Using crass 1.0.6
Using minitest 5.15.0
Using builder 3.2.4
Using digest 3.1.0
Using rack 2.2.3
Using io-wait 0.2.1
Using concurrent-ruby 1.1.9
Using websocket-extensions 0.1.5
Using marcel 1.0.2
Using mini_mime 1.1.2
Using bundler 2.3.3
Using timeout 0.2.0
Using nio4r 2.5.8
Using strscan 3.0.1
Using bindex 0.8.1
Using public_suffix 4.0.6
Using thor 1.2.1
Using erubi 1.10.0
Using matrix 0.4.2
Using regexp_parser 2.2.1
Using childprocess 4.1.0
Using method_source 1.0.0
Using redis 4.6.0
Using zeitwerk 2.5.4
Using io-console 0.5.11
Using diff-lcs 1.5.0
Using ffaker 2.20.0
Using pg 1.3.3
Using msgpack 1.4.5
Using rexml 3.2.5
Using rspec-support 3.11.0
Using rubyzip 2.3.2
Using net-protocol 0.1.2
Using rack-test 1.1.0
Using i18n 1.10.0
Using tzinfo 2.0.4
Using reline 0.3.1
Using sprockets 4.0.3
Using mail 2.7.1
Using nokogiri 1.13.3 (arm64-darwin)
Using rspec-mocks 3.11.0
Using websocket-driver 0.7.5
Using bootsnap 1.10.3
Using net-pop 0.1.1
Fetching puma 5.6.2
Using rspec-expectations 3.11.0
Using irb 1.4.1
Using net-imap 0.2.3
Using loofah 2.14.0
Using net-smtp 0.3.1
Using debug 1.4.0
Using rails-html-sanitizer 1.4.2
Using selenium-webdriver 4.1.0
Using rspec-core 3.11.0
Using xpath 3.2.0
Using webdrivers 5.0.0
Using addressable 2.8.0
Using activesupport 7.0.2.2
Using rails-dom-testing 2.0.3
Using globalid 1.0.0
Using activemodel 7.0.2.2
Using capybara 3.36.0
Using activerecord 7.0.2.2
Using factory_bot 6.2.0
Using actionview 7.0.2.2
Using activejob 7.0.2.2
Using actionpack 7.0.2.2
Using jbuilder 2.11.5
Using actioncable 7.0.2.2
Using activestorage 7.0.2.2
Using actionmailer 7.0.2.2
Using actionmailbox 7.0.2.2
Using railties 7.0.2.2
Using actiontext 7.0.2.2
Using sprockets-rails 3.4.2
Using turbo-rails 1.0.1
Using cssbundling-rails 1.1.0
Using rails 7.0.2.2
Using jsbundling-rails 1.0.2
Using rspec-rails 5.1.1
Using stimulus-rails 1.0.4
Using web-console 4.2.0
Using factory_bot_rails 6.2.0
Installing puma 5.6.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/jason/.rvm/gems/ruby-3.1.0/gems/puma-5.6.2/ext/puma_http11
/Users/jason/.rvm/rubies/ruby-3.1.0/bin/ruby -I /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0 -r
./siteconf20220307-61890-nqajx8.rb extconf.rb --with-cflags\=-Wno-error\=implicit-function-declaration
checking for BIO_read() in -lcrypto... *** 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=/Users/jason/.rvm/rubies/ruby-3.1.0/bin/$(RUBY_BASE_NAME)
    --with-puma_http11-dir
    --without-puma_http11-dir
    --with-puma_http11-include
    --without-puma_http11-include=${puma_http11-dir}/include
    --with-puma_http11-lib
    --without-puma_http11-lib=${puma_http11-dir}/lib
    --with-openssl-dir
    --without-openssl-dir
    --with-openssl-include
    --without-openssl-include=${openssl-dir}/include
    --with-openssl-lib
    --without-openssl-lib=${openssl-dir}/lib
    --with-openssl-config
    --without-openssl-config
    --with-pkg-config
    --without-pkg-config
    --with-crypto-dir
    --without-crypto-dir
    --with-crypto-include
    --without-crypto-include=${crypto-dir}/include
    --with-crypto-lib
    --without-crypto-lib=${crypto-dir}/lib
    --with-cryptolib
    --without-cryptolib
/Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/mkmf.rb:498:in `try_do': The compiler failed to generate an executable
file. (RuntimeError)
You have to install development tools first.
    from /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/mkmf.rb:591:in `try_link0'
    from /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/mkmf.rb:609:in `try_link'
    from /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/mkmf.rb:830:in `try_func'
    from /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/mkmf.rb:1065:in `block in have_library'
    from /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/mkmf.rb:1007:in `block in checking_for'
    from /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/mkmf.rb:362:in `block (2 levels) in postpone'
    from /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/mkmf.rb:332:in `open'
    from /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/mkmf.rb:362:in `block in postpone'
    from /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/mkmf.rb:332:in `open'
    from /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/mkmf.rb:358:in `postpone'
    from /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/mkmf.rb:1006:in `checking_for'
    from /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/mkmf.rb:1060:in `have_library'
    from extconf.rb:17:in `block in <main>'
    from extconf.rb:17:in `each'
    from extconf.rb:17:in `find'
    from extconf.rb:17:in `<main>'

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

  /Users/jason/.rvm/gems/ruby-3.1.0/extensions/arm64-darwin-20/3.1.0/puma-5.6.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/jason/.rvm/gems/ruby-3.1.0/gems/puma-5.6.2 for inspection.
Results logged to /Users/jason/.rvm/gems/ruby-3.1.0/extensions/arm64-darwin-20/3.1.0/puma-5.6.2/gem_make.out

  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:95:in `run'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:47:in `block in build'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/tempfile.rb:317:in `open'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:26:in `build'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:161:in `build_extension'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:195:in `block in build_extensions'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `each'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `build_extensions'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/installer.rb:847:in `build_extensions'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:28:in `install'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/bundler/source/rubygems.rb:204:in `install'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:54:in `install'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:186:in `do_install'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/bundler/worker.rb:62:in `apply_func'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/bundler/worker.rb:57:in `block in process_queue'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/bundler/worker.rb:54:in `loop'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/bundler/worker.rb:54:in `process_queue'
  /Users/jason/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/bundler/worker.rb:91:in `block (2 levels) in create_threads'

An error occurred while installing puma (5.6.2), and Bundler cannot continue.

In Gemfile:
  puma

我已经尝试过

xcode-select --install
但这并不能解决问题

我在下面的答案中修复了这个问题,但是有人可以解释一下它在做什么以及为什么强制从 rubygems 源安装似乎可以解决问题吗?

ruby-on-rails bundler puma
2个回答
11
投票

解决此问题的方法是从源代码安装它。

虽然消息说缺少 xcode-select 工具,但这不是问题。

gem install puma -v '5.6.2' --source 'https://rubygems.org/'

一旦完成此操作,我就可以成功重新运行

bundle install


0
投票

我在安装 rubocop (

gem install rubocop 1.56.3
) 时遇到此错误并收到了此“指导”:

You have not agreed to the Xcode license agreements. Please run 'sudo xcodebuild -license' from within a Terminal window to review and agree to the Xcode and Apple SDKs license.

所以我运行了命令,同意许可证,安装了 rubocop 后发现。

© www.soinside.com 2019 - 2024. All rights reserved.