Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR: Failed to build gem native extension on Windows

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

cmd output:

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 :(

I went through the link for troubleshoot in github Native gem extension Error and followed the instructions to solve, Yet the problem persists..

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

like image 793
Aks.. Avatar asked Oct 09 '14 10:10

Aks..


2 Answers

Downgrading ruby gems didn't work for me.

What did work was (with the latest version of ruby gems installed):

Open CMD as administrator and...

gem install json --platform=ruby --verbose

(Answer added by dannysmith here)

like image 132
Mahou5 Avatar answered Nov 11 '22 15:11

Mahou5


Finally after much research I found the culprit was the RubyGems version incompatibility with native extension gems!!!

I had ruby gems ver 2.4.1 but seems like >2.4.0 has these issues

gem update --system 2.3.0 did the trick for me :)

Refer: https://github.com/rubygems/rubygems/issues/977

like image 34
Aks.. Avatar answered Nov 11 '22 15:11

Aks..