简体   繁体   English

安装 rails 失败,“无法构建 gem 本机扩展”

[英]installing rails fails, “failed to build gem native extension”

I just installed ruby and gem on windows 10 x64, I checked that they were both installed.我刚刚在 Windows 10 x64 上安装了rubygem ,我检查了它们是否都已安装。 when I tried to install rails, it fails after a while.当我尝试安装 rails 时,它会在一段时间后失败。

see the link below for used commands有关使用的命令,请参阅下面的链接

El Administrator: Windows PowerShell 

PS C:\WINDOWS\system32> ruby -v 
ruby 2.4.3p205 (2017-12-14 revision 61247) (x64-mingw32] 
PS C:\WINDOWS\system32> gem --version 2.6.14 PS 
C:\WINDOWS\system32> gem install rails 
Temporarily enhancing PATH for MSYS/MINGW... 
Building native extensions. This could take a while... 
ERROR: Error installing rails: 
       ERROR: Failed to build gem native extension.

    current directory: CuRuby24-x64/lib/ruby/gems/2.4.0/gems/nio4r-2.2.0/ext/nio4r 
C:/Ruby24-x64/bin/ruby.exe -r asiteconf20180211-14528-1um1rd2.rb extconf.rb 

current directory: C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/nio4r-2.2.0/ext/nio4r 
make "DESTDIR=" clean 
'make' is not recognized as an internal or external command, 
operable program or batch file. 

current directory: C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/nio4r-2.2.0/ext/nio4r 
make "DESTDIR=" 
'make' is not recognized as an internal or external command, 
operable program or batch file. 

make failed, exit code 1 

Gem files will remain installed in C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/nio4r-2.2.0 for inspection. 
Results logged to C:/Ruby24-x64/lib/ruby/gems/2.4.0/extensions/x64-mingw32/2.4.0/nio4r-2.2.0/gem_make.out 
PS C:\WINDOWS\system32> 

I fixed this issue by using wsl.我使用 wsl 解决了这个问题。 The installation process is explained here . 这里解释安装过程。 I also had to use this to enable wsl on windows 10 build 16299.192(settings > system > about).我还必须使用在 Windows 10 版本 16299.192(设置 > 系统 > 关于)上启用 wsl。 also after i installed everything I ran sudo apt-get install nodejs and gem install rails .同样在我安装了所有东西之后,我运行了sudo apt-get install nodejsgem install rails After this, I could run the demo( wsl> rails new demo , wsl> cd demo , wsl> rails server ).在此之后,我可以运行演示( wsl> rails new demowsl> cd demowsl> rails server )。

You need the build tools to build native extensions.您需要构建工具来构建本机扩展。

sudo apt-get update
sudo apt-get install build-essential

Credit: How do I fix an error with Ruby Gems Installer on WSL?信用: 如何在 WSL 上修复 Ruby Gems 安装程序的错误?

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

相关问题 在Ubuntu 16.04上安装Rails时出错,无法构建gem本机扩展 - error installing rails on ubuntu 16.04 failed to build gem native extension 错误:安装Rails时无法构建gem本机扩展 - ERROR: Failed to build gem native extension when installing rails 在Rails上安装ruby时出错,无法构建gem本机扩展 - Error while installing ruby on rails,Failed to build gem native extension 安装Rails时“无法构建gem原生扩展” - “Failed to build gem native extension” when installing Rails 安装 fcgi 时出现 Rails 错误:无法构建 gem 原生扩展 - Rails error while installing fcgi: Failed to build gem native extension 安装 rails 时出错,无法构建 gem 本机扩展 - Error installing rails, failed to build gem native extension 安装rails时出错错误:无法构建gem本机扩展 - Error installing rails ERROR: Failed to build gem native extension Rails:安装 rmagick 时出错 - 错误:无法构建 gem 本机扩展 - Rails: Error installing rmagick - ERROR: Failed to build gem native extension 安装 Ruby on Rails 时出错:“无法构建 gem 本机扩展” - Error when installing Ruby on Rails: “Failed to build gem native extension” "<i>&quot;ERROR: Failed to build gem native extension.&quot;<\/i> “错误:无法构建 gem 原生扩展。”<\/b> <i>while installing Rails<\/i>在安装 Rails 时<\/b>" - "ERROR: Failed to build gem native extension." while installing Rails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM