The DevKit is a toolkit that makes it easy to build and use native C/C++ extensions such as RDiscount and RedCloth for Ruby on Windows.
Simply download, double-click, choose an installation directory, run the Ruby install helper script, possibly tweak a
config.yml file for your system specifics, and you’re ready to start using native Ruby extensions.
Download it, run it to extract it somewhere (permanent). Then cd to it, run “ruby dk.rb init” and “ruby dk.rb install” to bind it to ruby installations in your path.
Questions from the end user: I downloaded DevKit as exe file, unpacked it. Should I place it to some permanent location and then run installation scripts or I can simply run installation script and then delete the unpacked DevKit folder (in a second case I assume that this script injects DevKit into Ruby installation in some way)? – the answer to this question should be placed in first lines of installation guide as it is very important.
Answer: The file should be in its permanent location before running “ruby dk.rb init”.
One of the challenges many Ruby on Windows users have is how to easily use native RubyGems from the community such as the rdiscount or curb gems. In many cases this isn’t a problem because the extension author has provided a binary gem compatible with the users Ruby environment. In other cases, only the extension source code is available in the gem and the user is expected to have a “sane” environment installed and configured in order to build and use the native gem. A “sane” environment typically means a system with
make, gcc, sh and similar *nix build tools installed.
This expectation of a “sane” build environment is not always true for Windows users and is the primary reason why the DevKit was created. The DevKit, based upon MSYS and MinGW components, is an easy-to-install and easy-to-use solution for quickly setting up a “sane” build environment, enabling you to use most native RubyGems developed by the Ruby community.
We use the DevKit internally for the RubyInstaller project. The DevKit is used to build MRI Ruby and the required dependencies needed to deliver the RubyInstaller for Windows. Many community members also use the DevKit as their “foundation” toolkit for building other native software.
The DevKit is currently available for download as a self-extracting archive and a Windows installer is in development.
<RUBY_INSTALL_DIR>must not contain any whitespaces (like in “C:\Program Files\Ruby193”). This is very important because whitespaces in the path to your ruby installation will cause certain error messages as soon as you try to install gems which require the DevKit.
DevKit-3.4.5available at our archive downloads page. For RubyInstaller versions 1.8.7, 1.9.2, and 1.9.3 use the
DevKit 4.5.2from our main downloads page.
While installation is (in general) simple, please ensure you carefully follow each step below.
devkit-3.4.5r3-20091110.7z, its artifacts were extracted into each Ruby installation and need to be manually removed. Remove the
gcc.bat, make.bat, and sh.batstub batch files in
<RUBY_INSTALL_DIR>\devkitsubdirectory for each Ruby installation using the legacy DevKit.
C:\DevKit. NOTE: the SFX is really a 7-Zip archive with a bit of embedded magic. If you already have 7-Zip installed, you can simply right-click it and extract its contents as you would a normal 7z archive. In the instructions that follow, the directory that you selected is identified as
<DEVKIT_INSTALL_DIR>. NOTE: Do not rename this directory because once you install in Step 4 the path is hardcoded into the Ruby installation. If you do need to rename the directory re-run Step 4 with the
cd <DEVKIT_INSTALL_DIR>from Step 3 above.
ruby dk.rb initto generate the
config.ymlfile to be used later in this Step. Your installed Rubies will be listed there (only those installed by a RubyInstaller package are detected at present).
config.ymlfile to include installed Rubies not automatically discovered or remove Rubies you do not want to use the DevKit with.
ruby dk.rb reviewto review the list of Rubies to be enhanced to use the DevKit and verify the changes you made to it are correct.
ruby dk.rb installto DevKit enhance your installed Rubies. This step installs (or updates) an
operating_system.rbfile into the relevant directory needed to implement a RubyGems
pre_installhook and a
devkit.rbhelper library file into
<RUBY_INSTALL_DIR>\lib\ruby\site_ruby. NOTE: you may need to use the
--forceoption to update (with backup of the originals) the above mentioned files as discussed at the SFX DevKit upgrade FAQ entry.
gem install json --platform=ruby. JSON should install correctly and you should see
with native extensionsin the screen messages. Next run
ruby -rubygems -e "require 'json'; puts JSON.load('').inspect"to confirm that the json gem is working.
Once you’ve installed the DevKit you’ll discover there are but a few different types of native installation scenarios to deal with.
gem install bson_ext --platform=ruby. It’s crucial that you include the
--platform=rubyoption to force RubyGems to build the native gem rather than potentially installing an incorrect binary gem.
gem install curb --platform=ruby -- --with-curl-lib="C:/curl/bin" --with-curl-include="C:/curl/include". In addition, the curl library found in the directory specified with
--with-curl-libmust be on your
PATHfor use at runtime by the curb gem.
extconf.rbfile used to create a
Makefilefor the native library works correctly. To shorten the development cycle, the DevKit enables the developer to run
ruby -rdevkit extconf.rb.
To access all of the MSYS/MinGW tools from a Command Prompt shell, run the
devkitvars.bat helper script (lives in
<DEVKIT_INSTALL_DIR>) to update the shell’s
PATH environment variable. Similarly, if you’re using PowerShell, run the
devkitvars.ps1 helper script.
Alternatively, you can load the DevKit Environment programmatically using
As the DevKit is a fundamental part of the RubyInstaller build recipes, you can always build your own DevKit by simply:
git clone git://github.com/oneclick/rubyinstaller.git
rake devkit sfx=1
Then look in subdirectory, “pkg” for your newly built DevKit.
Now that you’ve installed the DevKit, you should be able to use many of the native C RubyGems without problems.
However, some extensions may require additional header and library files to also be installed, and still other extensions may need additional work done by the authors in order to get them to compile with the MSys/MinGW based DevKit. If you have problems, please drop us a line at our RubyInstaller Google Group
Last edited by Mark D. Blackwell,