错误:无法在Windows上构建本地扩展宝石

10
我安装“redcarpet”宝石时遇到以下错误。不过,我的朋友的机器上安装没有问题。(我想安装这个来运行yard) Ruby版本:1.9.3 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

更新: 按照https://github.com/oneclick/rubyinstaller/wiki/Development-Kit中提供的开发工具包安装说明进行安装后,当我测试json gem安装时也失败了 :(

我参考了在github上的故障排除链接Native gem extension Error并按照说明进行解决,但问题仍然存在..

我将这两个路径添加到环境变量中C:\\ruby_devkit\\bin;C:\\ruby_devkit\\mingw\\bin;,这样就不会出现Temporarily enhancing PATH to include DevKit...的命令行提示了。

2个回答

34

经过大量研究,我终于发现罪魁祸首是RubyGems版本与本机扩展宝石不兼容!!!

我使用了ruby gems ver 2.4.1,但似乎 >2.4.0 存在这些问题。

gem update --system 2.3.0 对我有帮助 :)

参考: https://github.com/rubygems/rubygems/issues/977


谢谢。谢谢。谢谢。 - Ryan
3
英雄!我尝试了大约37种解决方案...第38次终于成功了! - daddywoodland
非常顺利!非常感谢。 - tafuentesc
这个建议完全损坏了我的Ruby安装!现在无法升级到最新的gem,也不能帮助解决问题。 - user4674453
2
对我来说,只需使用 gem update --system 命令更新即可解决问题。不要降级,这样做无法解决问题! - Private_GER

6

我尝试过降级ruby gems,但没有成功。

成功的方法是(安装最新版本的ruby gems):

以管理员身份打开CMD并...

gem install json --platform=ruby --verbose

(此处由dannysmith 此处添加的答案)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接