简体   繁体   English

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

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

I'm getting the below error while installing ' redcarpet ' gem. 我在安装' redcarpet '宝石时遇到以下错误。 It got installed without issue on my friends machine though. 它虽然在我的朋友机器上安装没有问题。 (I want to install this to run yard ) Ruby version: 1.9.3 (我想安装它来运行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-Kit When 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 Error and 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; 我添加了两个路径到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 这将删除Temporarily enhancing PATH to include DevKit...的行, Temporarily enhancing PATH to include DevKit...出现在cmd上的Temporarily enhancing PATH to include DevKit...

Finally after much research I found the culprit was the RubyGems version incompatibility with native extension gems!!! 经过大量研究后,我发现罪魁祸首是RubyGems版本与原生扩展宝石的不兼容性!

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.0 did the trick for me :) gem update --system 2.3.0为我做了诀窍:)

Refer: https://github.com/rubygems/rubygems/issues/977 请参阅: https//github.com/rubygems/rubygems/issues/977

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 dannysmith here ) 丹尼史密斯 在这里添加了答案

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

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