Failed to build gem native extension on Windows

So there I was lovely new computer, I installed Ruby 193, old tests which needed it, don’t ask, and of cause the ruby dev kit, then a quick bundle install and I will be ready to go, but instead I get a cryptic message from the install saying something like.

C:\devkit>gem install rdiscount --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rdiscount:
       ERROR: Failed to build gem native extension.

C:/ruby/bin/ruby.exe extconf.rb
C:/ruby/bin/ruby.exe: No such file or directory -- extconf.rb
(LoadError)

after a bit of googling with bing, I turned up the Windows Rubyinstaller Troubleshooting instructions.

Now even though I had not installed ruby using the installer, but using Chocolatey the trouble shooter did have a nice section displaying the text above which was close to what I had on my screen, apparently there are some registry settings that effect the dev kit.

Reading down it shows 4 registry keys

REG QUERY "HKCU\Software\Microsoft\Command Processor" /s
REG QUERY "HKLM\Software\Microsoft\Command Processor" /s
REG QUERY "HKCU\Software\Wow6432Node\Microsoft\Command Processor" /s
REG QUERY "HKLM\Software\Wow6432Node\Microsoft\Command Processor" /s

that need to be checked, and the expected results, all but the third one worked fine, the third one, simply did not exist in my registry!

Another quick google with bing and I discovered that happily I was not the only one with the issue, but I did not find any real solutions.

The following is what I did to solve the issue, it “worked on my machine”, but editing the registry comes with risks and your results may be different.

I had a look at the registry entries for the ones that worked, both the HKCM keys

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor
    CompletionChar    REG_DWORD    0x40
    DefaultColor    REG_DWORD    0x0
    EnableExtensions    REG_DWORD    0x1
    PathCompletionChar    REG_DWORD    0x40

HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Command Processor
    CompletionChar    REG_DWORD    0x40
    DefaultColor    REG_DWORD    0x0
    EnableExtensions    REG_DWORD    0x1
    PathCompletionChar    REG_DWORD    0x40

and both entries were the same, one for the 32bit environment and one for the 64 bit.  So taking a quick leap in the dark and looking at the working entry for HKCU I fired up RegEdit and added an entry for the missing key making it exactly the same as the existing entry.

HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Command Processor
    CompletionChar    REG_DWORD    0x9
    DefaultColor    REG_DWORD    0x0
    EnableExtensions    REG_DWORD    0x1
    PathCompletionChar    REG_DWORD    0x9

and for reasons I do not understand it all worked, native gems now build correctly on my machine and I can complete my bundle install.

Advertisements

About Duncan Butler

Trying to be a very agile software developer, working in C# with Specflow, Nunit and Machine Specifications, and in the evening having fun with Ruby and Rails
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Failed to build gem native extension on Windows

  1. Sarah says:

    Hey,

    Thanks for this article. I have the same problem. I was wondering can you help me enter the new registry item? I’m a bit unsure how to do this. Thanks.
    Sarah

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s