ruby 错误:无法在 Windows 上构建 gem 本机扩展
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26276207/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ERROR: Failed to build gem native extension on Windows
提问by Aks..
I'm getting the below error while installing 'redcarpet' gem. It got installed without issue on my friends machine though. (I want to install this to run yard)
Ruby version: 1.9.3
安装“ redcarpet” gem 时出现以下错误。不过,它在我朋友的机器上安装没有问题。(我想安装它来运行yard) Ruby 版本:1.9.3
cmd output:
cmd输出:
D:\Learning\Common_POM_FW\SampleProjects>yard
[error]: Missing 'redcarpet' gem for Markdown formatting. Install it with `gem install redcarpet`
D:\Learning\Common_POM_FW\SampleProjects>gem install redcarpet
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing redcarpet:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe -r ./siteconf20141009-6544-978w4t.rb extconf.rb
creating Makefile
make clean
Makefile:165: *** target pattern contains no `%'. Stop.
make
Makefile:165: *** target pattern contains no `%'. Stop.
make failed, exit code 2
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/redcarpet-3.1.2 for inspectio
n.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/extensions/x86-mingw32/1.9.1/redcarpet-3.1.2/gem_ma
ke.out
UPDATE:With the devkit installation instructions provided at https://github.com/oneclick/rubyinstaller/wiki/Development-KitWhen I test the installation with json gem it fails there too :(
更新:使用https://github.com/oneclick/rubyinstaller/wiki/Development-Kit提供的 devkit 安装说明当我使用 json gem 测试安装时,它也失败了 :(
I went through the link for troubleshoot in github Native gem extension Errorand followed the instructions to solve, Yet the problem persists..
我通过github Native gem extension Error中的故障排除链接并按照说明解决,但问题仍然存在..
I added the two paths to Env var C:\\ruby_devkit\\bin;C:\\ruby_devkit\\mingw\\bin;This removes the line Temporarily enhancing PATH to include DevKit...from appearing on cmd
我将两条路径添加到 Env varC:\\ruby_devkit\\bin;C:\\ruby_devkit\\mingw\\bin;这删除了Temporarily enhancing PATH to include DevKit...出现在 cmd 上的行
回答by Aks..
Finally after much research I found the culprit was the RubyGems version incompatibility with native extension gems!!!
最后经过大量研究,我发现罪魁祸首是 RubyGems 版本与本机扩展 gems 不兼容!!!
I had ruby gems ver 2.4.1 but seems like >2.4.0 has these issues
我有 ruby gems ver 2.4.1 但似乎 >2.4.0 有这些问题
gem update --system 2.3.0did the trick for me :)
gem update --system 2.3.0为我做了诀窍:)
回答by Mahou5
Downgrading ruby gems didn't work for me.
降级红宝石对我不起作用。
What did work was (with the latest version of ruby gems installed):
有效的是(安装了最新版本的 ruby gems):
Open CMD as administrator and...
以管理员身份打开 CMD 并...
gem install json --platform=ruby --verbose
(Answer added by dannysmithhere)
(答案由dannysmith在这里添加)

