If you’re stuck trying to run Ruby on Windows, one barrier you might have encountered is in trying to install a gem like ruby-debug or rdiscount. You’ll have seen an error like this:
%gem install ruby-debug
Building native extensions. This could take a while...
ERROR: Error installing ruby-debug:
ERROR: Failed to build gem native extension.
C:/Ruby187/bin/ruby.exe extconf.rb
creating Makefile
make
'make' is not recognized as an internal or external command, operable program or batch file.
Gem files will remain installed in C:/Ruby187/lib/ruby/gems/1.8/gems/linecache-0.43 for inspection.
Results logged to C:/Ruby187/lib/ruby/gems/1.8/gems/linecache-0.43/ext/gem_make.out
That’s no fun.
The good news is, the lovely guys at Ruby Installer have put together a fix, called the DevKit. This installs the low-level bits and pieces needed to build those pesky native extensions on your Windows machine. There are a couple of manual steps which I didn’t find especially clear, so I’m documenting them here.
- Download the DevKit self-extracting archive here
- Run the archive, and when prompted, choose to extract it to C:\DevKit
- When the archive has finished unpacking, open a command prompt in C:\DevKit and run
ruby dk.rb init
ruby dk.rb install - That’s it. You can test it using:
gem install ruby-debug
Hooray!
Thanks alot for the solution. I can now install it on my Windows machine!
is there any way to do this with Jruby in windows, like
Jruby -S gem install ruby-debug
Thanks for this. Was pulling my hair out.
I’m afraid this did not help (Windows 7 Home Premium):-
[C:\DevKit]ruby dk.rb init
[INFO] found RubyInstaller v1.9.3 at C:/Ruby193
Initialization complete! Please review and modify the auto-generated
‘config.yml’ file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.
[C:\DevKit]b config.yml
[C:\DevKit]ruby dk.rb install
[INFO] RubyGems override already in place for C:/Ruby193, skipping.
[INFO] Installing C:/Ruby193/lib/ruby/site_ruby/devkit.rb
[C:\DevKit]cd –
[C:\Indexing]gem install ruby-debug
Fetching: rbx-require-relative-0.0.9.gem (100%)
Fetching: linecache-0.46.gem (100%)
ERROR: Error installing ruby-debug:
The ‘linecache’ native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from ‘http://rubyinstaller.org/downloads’ and follow the instructions
at ‘http://github.com/oneclick/rubyinstaller/wiki/Development-Kit’