2012年6月14日木曜日

Windows7環境にgem install rails したらjsonのgemでエラー

Windows7(64bit)にruby1.9.3をいれて gem install rails すると

ERROR:  Error installing json:
        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'
こんな感じのエラーが出る。 どうやらgem installの過程でソースコンパイルをしようとしているがコンパイラとかその辺がないのでエラーになっている様子。

http://github.com/oneclick/rubyinstaller/wiki/Development-Kit

って書いてあるので見てみるとDevKit 4.5.2を入れなさいと。

 RubyInstaller download から「DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe」をダウンロードして適当な場所に解凍する。
回答したディレクトリ直下にdk.rb というスクリプトがあってこいつでインストールする。

  1. ruby dk.rb init する
    config.ymlが作られ、中にrubyのパスが書かれるらしい。
  2. ruby dk.rb install する
    なんかインストールされる。
> ruby dk.rb init

[INFO] found RubyInstaller v1.9.3 at C:/dev/Ruby/193p194

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.

> ruby dk.rb install

[INFO] Updating convenience notice gem override for 'C:/dev/Ruby/193p194'
[INFO] Installing 'C:/dev/Ruby/193p194/lib/ruby/site_ruby/devkit.rb'
これでインストールできるようになった
> gem install json
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed json-1.7.3
1 gem installed
Installing ri documentation for json-1.7.3...
Installing RDoc documentation for json-1.7.3...

0 件のコメント: