読者です 読者をやめる 読者になる 読者になる

WindowsでNativeExtensionを入れるためにDevelopment-Kitを入れる

Ruby Windows

なんかDevKitを入れろと言われています。

Windows.Ruby.native extensions.........
Installing json (1.7.5)
Gem::InstallError: The 'json' 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'
An error occurred while installing json (1.7.5), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.5'` succeeds before bundling.

上記に書いてあることをやればいいです。

インストールするパスは例にもあるように空白を含まないパスのほうがいいですね。
例のまんま入れることにします

Left double-click the self-extracting executable (SFX) downloaded from Step 2 and choose a directory (without spaces) to install the DevKit artifacts into. For example, 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

インストールパスに移動して下記コマンドを実行

$ 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.

config.ymlにRubyのパスを書くのですが見つけてくれたようで書かれておりました

確認

$ ruby dk.rb review
Based upon the settings in the 'config.yml' file generated
from running 'ruby dk.rb init' and any of your customizations,
DevKit functionality will be injected into the following Rubies
when you run 'ruby dk.rb install'.

Install

$ ruby dk.rb install
[INFO] Updating convenience notice gem override for 'C:/Ruby193'
[INFO] Installing 'C:/Ruby193/lib/ruby/site_ruby/devkit.rb'

これでNativeExtensionが使えるようになります。