簡體   English   中英

rails 5.0.0 安裝“nio4r”時:無法構建 gem 本機擴展

[英]rails 5.0.0 when installing “nio4r” : Failed to build gem native extension

這是日志: http : //pastebin.com/CAgur9xd

Installing nio4r 1.2.1 with native extensions

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

    C:/RailsInstaller/Ruby2.2.0/bin/ruby.exe -r ./siteconf20160720-8272-c88sgk.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
        --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:/RailsInstaller/Ruby2.2.0/bin/$(RUBY_BASE_NAME)
C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.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:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:587:in `try_cpp'
         from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:1060:in `block in have_header'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:911:in `block in checking_for'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:351:in `block (2 levels) in postpone'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:321:in `open'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:351:in `block in postpone'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:321:in `open'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:347:in `postpone'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:910:in `checking_for'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:1059:in `have_header'
        from extconf.rb:3:in `<main>'

extconf failed, exit code 1

安裝包時,它返回(從日志中的第 117 行開始):

Installing nio4r 1.2.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

所以無法安裝該包。 它在最后返回:

An error occurred while installing nio4r (1.2.1), and Bundler cannot continue.
Make sure that `gem install nio4r -v '1.2.1'` succeeds before bundling.

注意:我已經嘗試了其他問題中的解決方案,但還是一樣。 如果可以手動安裝“nio4r”,請告訴我如何安裝。

我在嘗試將 Rails 升級到 V5.0.0 時遇到了同樣的問題,我按照此說明進行操作,它運行良好。 在此處閱讀“安裝 Ruby DevKit”部分 >> http://jekyll-windows.juthilo.com/1-ruby-and-devkit/

Fedora 64位解決方案

sudo dnf install redhat-rpm-config

我遇到了類似的問題,運行此命令解決了我的問題。

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

現在您可以成功運行bundle install之后。

我在設置導軌時也遇到了這個問題。 (正在尋找 php 的替代品)。

  • 我意識到我已經用 x64 Devkit 安裝了 x86 ruby​​,所以我首先下載了 x64 ruby​​,我安裝並卸載了 x86 版本。 我確保我的路徑變量設置得很好。
  • 然后我使用此頁面上的說明安裝了 devkit http://rubyonwindowsguides.github.io/book/ch02-04.html
  • 最后我安裝了 rails,這次它工作正常,沒有錯誤

希望這可以幫助

我兒子為我解決了這個問題。 問題是我先安裝了 Ruby,然后是 Rails 安裝程序。 所以我不得不卸載 Ruby 並僅使用 Rails 安裝程序重新安裝。

在 Ubuntu 16.04 上有同樣的問題。 我做了什么來解決這個問題:

刪除 Gemfile.lock : sudo rm Gemfile.lock 安裝的 Ruby-Dev:

sudo apt-add-repository ppa:brightbox/ruby-ng sudo apt-get 更新 sudo apt-get install ruby​​2.4-dev

和重要的一步:重新啟動!

這可能與: 安裝 Nokogiri 時 GCC 編譯錯誤有關

我發現了一個錯誤。 我的系統上安裝了 2 個 gcc 版本,我只運行brew unlink gcc就解決了問題。

這也是我的情況。 benw unlink gcc工作

刪除 Gemfile.lock 並運行 bundle install 命令

引用您的日志輸出:

編譯器無法生成可執行文件。 (RuntimeError) 你必須先安裝開發工具。

在 Windows 上,您需要安裝 DevKit才能編譯 gems。

如果您使用 Windows 並安裝了 RubyInstaller 版本大於或等於 2.4 的 ruby​​,那么您不應該從 RubyInstaller 網站安裝 DevKit,而只能使用在 RubyInstaller 之后安裝的“msys64”(確保鍵入數字 3 以安裝兩個 msys和 mingw)。 從PATH環境變量中刪除devkit目錄及其路徑,所以當rubygems嘗試安裝nio4r並調用C編譯器時,它會調用msys編譯器。 在此處閱讀https://rubyinstaller.org/2017/05/25/rubyinstaller-2.4.1-1-released.html了解有關 RubyInstaller 中 MSYS2 和 DevKit 的更多信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM