如何在Mac10.13的Rails 5.1.6上修复捆绑包“ nio4r错误” [英] How to fix a bundle “nio4r error” on Rails 5.1.6 on mac10.13

查看:118
本文介绍了如何在Mac10.13的Rails 5.1.6上修复捆绑包“ nio4r错误”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目上使用ruby 2.5.0,rails 5.1.6,rvm 1.29.3。

I use ruby 2.5.0, rails 5.1.6, rvm 1.29.3 on my project.

我在这篇文章中找到了一些答案如何修复捆绑包安装 ; nio4r错误在Rails 5.0.0 上,但返回相同的错误。

I find some answer on this post How to fix a bundle install "nio4r error" on Rails 5.0.0,but return the same error.

在运行rails -v时,返回

when run rails -v, it return

Could not find nio4r-2.3.0 in any of the sources
Run `bundle install` to install missing gems.

然后我运行bundle update或bundle,它返回

then I run bundle update or bundle , it return

Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies........................
Using rake 12.3.1
Using concurrent-ruby 1.0.5
Using i18n 1.0.1
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 5.1.6
Using builder 3.2.3
Using erubi 1.7.1
Using mini_portile2 2.3.0
Using nokogiri 1.8.2
Using rails-dom-testing 2.0.3
Using crass 1.0.4
Using loofah 2.2.2
Using rails-html-sanitizer 1.0.4
Using actionview 5.1.6
Using rack 2.0.5
Using rack-test 1.0.0
Using actionpack 5.1.6
Fetching nio4r 2.3.1 (was 2.3.0)
Installing nio4r 2.3.1 (was 2.3.0) with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/apple/.rvm/gems/ruby-2.5.0/gems/nio4r-2.3.1/ext/nio4r
/Users/apple/.rvm/rubies/ruby-2.5.0/bin/ruby -r ./siteconf20180529-30171-1q1064e.rb extconf.rb --with-cflags=-std=c99
checking for unistd.h... *** 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
    --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/apple/.rvm/rubies/ruby-2.5.0/bin/$(RUBY_BASE_NAME)
/Users/apple/.rvm/rubies/ruby-2.5.0/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 /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:590:in `try_cpp'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:1097:in `block in have_header'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:947:in `block in checking_for'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:350:in `block (2 levels) in postpone'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:320:in `open'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:350:in `block in postpone'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:320:in `open'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:346:in `postpone'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:946:in `checking_for'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:1096:in `have_header'
    from extconf.rb:14:in `<main>'

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

  /Users/apple/.rvm/gems/ruby-2.5.0/extensions/x86_64-darwin-17/2.5.0/nio4r-2.3.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/apple/.rvm/gems/ruby-2.5.0/gems/nio4r-2.3.1 for inspection.
Results logged to /Users/apple/.rvm/gems/ruby-2.5.0/extensions/x86_64-darwin-17/2.5.0/nio4r-2.3.1/gem_make.out

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

In Gemfile:
  animate-rails was resolved to 1.0.10, which depends on
    rails was resolved to 5.1.6, which depends on
      actioncable was resolved to 5.1.6, which depends on
        nio4r

运行时

gem install nio4r -v '2.3.1' --source 'https://rubygems.org/'

返回

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

    current directory: /Users/apple/.rvm/gems/ruby-2.5.0/gems/nio4r-2.3.0/ext/nio4r
/Users/apple/.rvm/rubies/ruby-2.5.0/bin/ruby -r ./siteconf20180529-30246-h59is8.rb extconf.rb
checking for unistd.h... *** 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
    --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/apple/.rvm/rubies/ruby-2.5.0/bin/$(RUBY_BASE_NAME)
/Users/apple/.rvm/rubies/ruby-2.5.0/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 /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:590:in `try_cpp'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:1097:in `block in have_header'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:947:in `block in checking_for'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:350:in `block (2 levels) in postpone'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:320:in `open'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:350:in `block in postpone'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:320:in `open'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:346:in `postpone'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:946:in `checking_for'
    from /Users/apple/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:1096:in `have_header'
    from extconf.rb:14:in `<main>'

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

  /Users/apple/.rvm/gems/ruby-2.5.0/extensions/x86_64-darwin-17/2.5.0/nio4r-2.3.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/apple/.rvm/gems/ruby-2.5.0/gems/nio4r-2.3.0 for inspection.
Results logged to /Users/apple/.rvm/gems/ruby-2.5.0/extensions/x86_64-darwin-17/2.5.0/nio4r-2.3.0/gem_make.out

我的mkmf.log是

my mkmf.log is

"gcc -o conftest -I/Users/apple/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin17 -I/Users/apple/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/apple/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -std=c99 conftest.c  -L. -L/Users/apple/.rvm/rubies/ruby-2.5.0/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl@1.1/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl@1.1/lib     -lruby.2.5.0  -lpthread -lgmp -ldl -lobjc "
In file included from conftest.c:1:
In file included from /Users/apple/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby.h:33:
In file included from /Users/apple/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:29:
In file included from /Users/apple/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/defines.h:120:
In file included from /usr/include/stdlib.h:65:
In file included from /usr/include/sys/wait.h:110:
In file included from /usr/include/sys/resource.h:72:
In file included from /usr/local/include/stdint.h:59:
In file included from /usr/local/include/stdint.h:59:
In file included from /usr/local/include/stdint.h:59:
In file included from /usr/local/include/stdint.h:59:
In file included from /usr/local/include/stdint.h:59:
In file included from /usr/local/include/stdint.h:59:
In file included from /usr/local/include/stdint.h:59:
In file included from /usr/local/include/stdint.h:59:
In file included from /usr/local/include/stdint.h:59:
In file included from /usr/local/include/stdint.h:59:

/usr/local/include/stdint.h:2:10: error: #include nested too deeply
#include <stddef.h>
         ^
/usr/local/include/stdint.h:59:11: error: #include nested too deeply
# include <stdint.h>
          ^
/usr/local/include/stdint.h:72:11: error: #include nested too deeply
# include <sys/types.h>
          ^
/usr/local/include/stdint.h:76:10: error: #include nested too deeply
#include <limits.h>
         ^
/usr/local/include/stdint.h:82:11: error: #include nested too deeply
# include <inttypes.h>
          ^
In file included from conftest.c:1:
In file included from /Users/apple/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby.h:33:
In file included from /Users/apple/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:29:
In file included from /Users/apple/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/defines.h:120:
In file included from /usr/include/stdlib.h:65:
In file included from /usr/include/sys/wait.h:110:
/usr/include/sys/resource.h:197:2: error: unknown type name 'uint64_t'
        uint64_t ri_user_time;
        ^
/usr/include/sys/resource.h:198:2: error: unknown type name 'uint64_t'
        uint64_t ri_system_time;
        ^
/usr/include/sys/resource.h:199:2: error: unknown type name 'uint64_t'
        uint64_t ri_pkg_idle_wkups;
        ^
/usr/include/sys/resource.h:200:2: error: unknown type name 'uint64_t'
/usr/include/sys/resource.h:201:2: error: unknown type name 'uint64_t'
        uint64_t ri_pageins;
        ^
/usr/include/sys/resource.h:202:2: error: unknown type name 'uint64_t'
        uint64_t ri_wired_size;
        ^
/usr/include/sys/resource.h:203:2: error: unknown type name 'uint64_t'
        uint64_t ri_resident_size;
        ^
/usr/include/sys/resource.h:204:2: error: unknown type name 'uint64_t'
        uint64_t ri_phys_footprint;
        ^
/usr/include/sys/resource.h:205:2: error: unknown type name 'uint64_t'
        uint64_t ri_proc_start_abstime;
        ^
/usr/include/sys/resource.h:206:2: error: unknown type name 'uint64_t'
        uint64_t ri_proc_exit_abstime;
        ^
/usr/include/sys/resource.h:211:2: error: unknown type name 'uint64_t'
        uint64_t ri_user_time;
        ^
/usr/include/sys/resource.h:212:2: error: unknown type name 'uint64_t'
        uint64_t ri_system_time;
        ^
/usr/include/sys/resource.h:213:2: error: unknown type name 'uint64_t'
        uint64_t ri_pkg_idle_wkups;

/usr/include/sys/resource.h:214:2: error: unknown type name 'uint64_t'
        uint64_t ri_interrupt_wkups;
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */   


推荐答案

首先在下面尝试配置

bundle config build.nio4r --with-cflags="-std=c99"
bundle

之后

brew update 

bundle update

这篇关于如何在Mac10.13的Rails 5.1.6上修复捆绑包“ nio4r错误”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆