简体   繁体   English

错误:无法在Windows 10上构建gem本机扩展

[英]ERROR: Failed to build gem native extension on Windows 10

I have this problem while installing rails on Windows 10. I have tried to many things but none of them worked. 我在Windows 10上安装滑轨时遇到了这个问题。我尝试了很多事情,但是没有一个起作用。 Please help!!! 请帮忙!!!
This is what I have done. 这就是我所做的。 It looks like I have two errors. 看来我有两个错误。
ERROR: Failed to build gem native extension. 错误:无法生成gem本机扩展。
You have to install development tools first. 您必须先安装开发工具。

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\Users\Perdorues>ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]

C:\Users\Perdorues>gem -v
2.6.10

C:\Users\Perdorues>gem install rails --no-rdoc --no-ri
Fetching: i18n-0.8.1.gem (100%)
Successfully installed i18n-0.8.1
Fetching: thread_safe-0.3.6.gem (100%)
Successfully installed thread_safe-0.3.6
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: concurrent-ruby-1.0.5.gem (100%)
Successfully installed concurrent-ruby-1.0.5
Fetching: activesupport-5.0.2.gem (100%)
Successfully installed mini_portile2-2.1.0
Fetching: nokogiri-1.7.0.1-x64-mingw32.gem (100%)
Nokogiri is built with the packaged libraries: libxml2-2.9.4, libxslt-1.1.29, zlib-1.2.8, libiconv-1.14.
Successfully installed nokogiri-1.7.0.1-x64-mingw32
Fetching: loofah-2.0.3.gem (100%)
Successfully installed loofah-2.0.3
Fetching: rails-html-sanitizer-1.0.3.gem (100%)
Successfully installed rails-html-sanitizer-1.0.3
Fetching: rails-dom-testing-2.0.2.gem (100%)
Successfully installed rails-dom-testing-2.0.2
Fetching: builder-3.2.3.gem (100%)
Successfully installed builder-3.2.3
Fetching: erubis-2.7.0.gem (100%)
Successfully installed erubis-2.7.0
Fetching: actionview-5.0.2.gem (100%)
Successfully installed actionview-5.0.2
Fetching: actionpack-5.0.2.gem (100%)
Successfully installed actionpack-5.0.2
Fetching: activemodel-5.0.2.gem (100%)
Successfully installed activemodel-5.0.2
Fetching: arel-7.1.4.gem (100%)
Successfully installed arel-7.1.4
Fetching: activerecord-5.0.2.gem (100%)
Successfully installed activerecord-5.0.2
Fetching: globalid-0.3.7.gem (100%)
Successfully installed globalid-0.3.7
Fetching: activejob-5.0.2.gem (100%)
Successfully installed activejob-5.0.2
Fetching: mime-types-data-3.2016.0521.gem (100%)
Successfully installed mime-types-data-3.2016.0521
Fetching: mime-types-3.1.gem (100%)
Successfully installed mime-types-3.1
Fetching: mail-2.6.4.gem (100%)
Successfully installed mail-2.6.4
Fetching: actionmailer-5.0.2.gem (100%)
Successfully installed actionmailer-5.0.2
Fetching: nio4r-2.0.0.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

current directory: C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/nio4r-2.0.0/ext/nio4r
C:/Ruby23-x64/bin/ruby.exe -r ./siteconf20170312-10676-aq6a8o.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
    --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=C:/Ruby23-x64/bin/$(RUBY_BASE_NAME)
C:/Ruby23-x64/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 C:/Ruby23-x64/lib/ruby/2.3.0/mkmf.rb:587:in `try_cpp'
    from C:/Ruby23-x64/lib/ruby/2.3.0/mkmf.rb:1091:in `block in have_header'
    from C:/Ruby23-x64/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
    from C:/Ruby23-x64/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
    from C:/Ruby23-x64/lib/ruby/2.3.0/mkmf.rb:320:in `open'
    from C:/Ruby23-x64/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
    from C:/Ruby23-x64/lib/ruby/2.3.0/mkmf.rb:320:in `open'
    from C:/Ruby23-x64/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
    from C:/Ruby23-x64/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
    from C:/Ruby23-x64/lib/ruby/2.3.0/mkmf.rb:1090:in `have_header'
    from extconf.rb:5:in `<main>'

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

  C:/Ruby23-x64/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/nio4r-2.0.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/nio4r-2.0.0 for inspection.
Results logged to C:/Ruby23-x64/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/nio4r-2.0.0/gem_make.out

When using ruby on Windows with I presume ruby installer you should also install ruby development kit . 当我在Windows上使用ruby安装程序来安装ruby时,还应该安装ruby开发工具包 I think this will solve your problem. 我认为这可以解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM