JRubyでgem
まずはgemをインストール、かと思いきや、$JRUBY_HOME/bin/gemが既にありました。
しかし、それを実行するには、jrubyを明示的に指定しないといけません。
なので、.bashrcに
alias jgem='jruby $JRUBY_HOME/bin/gem'
と書いて、以降はjgemでインストールしていく。
まずはお約束のrakeとかrailsとかをインストール
$ jgem install rake $ jgem install rails
なんの問題もなく完了。
私が使いたかったmechanizeは、hpricotを事前にインストールするところで少しつまずいた。
単純に、以下のようにタイプしてもエラーとなる。
$ jgem install hpricot ... Need to update 2 gems from http://gems.rubyforge.org .. complete Select which gem to install for your platform (java) 1. hpricot 0.5 (mswin32) 2. hpricot 0.5 (ruby) 3. hpricot 0.4 (mswin32) 4. hpricot 0.4 (ruby) 5. Skip this gem 6. Cancel installation > 2 Building native extensions. This could take a while... Error opening script file: extconf.rb (No such file or directory) ERROR: While executing gem ... (Gem::Installer::ExtensionBuildError) ERROR: Failed to build gem native extension. ...
開発サイトを見ると、開発中のものを取得するには、
$ gem install hpricot --source http://code.whytheluckystiff.net
としなさいとのことだったので、その通りすると、jruby版というのが候補に出てきてインストールできるようになる。
$ jgem install hpricot --source http://code.whytheluckystiff.net Bulk updating Gem source index for: http://code.whytheluckystiff.net Select which gem to install for your platform (java) 1. hpricot 0.5.140 (ruby) 2. hpricot 0.5.140 (jruby) 3. hpricot 0.5.140 (mswin32) 4. hpricot 0.5.136 (mswin32) 5. hpricot 0.5.136 (jruby) 6. hpricot 0.5.136 (ruby) 7. hpricot 0.5.134 (mswin32) 8. hpricot 0.5.134 (ruby) 9. hpricot 0.5.134 (jruby) 10. hpricot 0.5.123 (jruby) 11. hpricot 0.5.123 (ruby) 12. hpricot 0.5.123 (mswin32) 13. Skip this gem 14. Cancel installation > 2 Successfully installed hpricot-0.5.140-jruby Installing ri documentation for hpricot-0.5.140-jruby... Installing RDoc documentation for hpricot-0.5.140-jruby...
後は、mechanizeをいつもどおり、gem install mechanizeな感じでインストールすればOK、なようす。