Mavericksでappengine-jruby環境を作る
GAEでJRuby開発を行うためのgemであるappengine-jrubyというgemを入れるのに苦労したのでメモしておきます.
rbenvの導入ができている前提で話を進めます.
ruby1.8.7を入れる
appengine-jrubyはruby1.9以降では動きません. そこでruby1.8.7を入れます.
$ CC=/usr/local/bin/gcc-4.8 rbenv install 1.8.7-p375
通常,Marveriks環境だとインストール時に以下のようなエラーが起きる
~ $ rbenv install 1.8.7-p375 Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Checking out http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_7... Installing ruby-1.8.7-p375... BUILD FAILED Inspect or clean up the working tree at /var/folders/m7/zpgv_gzn1fj1pqb2tf2h3ycm0000gn/T/ruby-build.20140129232450.61809 Results logged to /var/folders/m7/zpgv_gzn1fj1pqb2tf2h3ycm0000gn/T/ruby-build.20140129232450.61809.log Last 10 log lines: Checked out revision 44351. /var/folders/m7/zpgv_gzn1fj1pqb2tf2h3ycm0000gn/T/ruby-build.20140129232450.61809/ruby-1.8.7-p375 /var/folders/m7/zpgv_gzn1fj1pqb2tf2h3ycm0000gn/T/ruby-build.20140129232450.61809 ~/Develop configure: WARNING: unrecognized options: --with-readline-dir checking build system type... i686-apple-darwin13.0.0 checking host system type... i686-apple-darwin13.0.0 checking target system type... i686-apple-darwin13.0.0 checking whether the C compiler works... no configure: error: in `/var/folders/m7/zpgv_gzn1fj1pqb2tf2h3ycm0000gn/T/ruby-build.20140129232450.61809/ruby-1.8.7-p375': configure: error: C compiler cannot create executables See `config.log' for more details BUILD FAILED Inspect or clean up the working tree at /var/folders/m7/zpgv_gzn1fj1pqb2tf2h3ycm0000gn/T/ruby-build.20140129232450.61809 Results logged to /var/folders/m7/zpgv_gzn1fj1pqb2tf2h3ycm0000gn/T/ruby-build.20140129232450.61809.log Last 10 log lines: /var/folders/m7/zpgv_gzn1fj1pqb2tf2h3ycm0000gn/T/ruby-build.20140129232450.61809/ruby-1.8.7-p375 /var/folders/m7/zpgv_gzn1fj1pqb2tf2h3ycm0000gn/T/ruby-build.20140129232450.61809 ~/Develop configure: WARNING: unrecognized options: --with-readline-dir checking build system type... i686-apple-darwin13.0.0 checking host system type... i686-apple-darwin13.0.0 checking target system type... i686-apple-darwin13.0.0 checking whether the C compiler works... no configure: error: in `/var/folders/m7/zpgv_gzn1fj1pqb2tf2h3ycm0000gn/T/ruby-build.20140129232450.61809/ruby-1.8.7-p375': configure: error: C compiler cannot create executables See `config.log' for more details make: *** No targets specified and no makefile found. Stop.
これはMarvericksになってgccが変更されたためだ(ったはず...)
そこで別のgccへのパスを指定する必要が出てくる
あ、あとrehashしてくださいね
appengine-jrubyを入れる
以下のコマンドを実行すれば依存関係も含めgemがインストールされる
$ gem install google-appengine
と思ったら大間違いである.
ここで通常であれば以下のエラーが出る
~ $ gem install google-appengine Fetching: rack-1.5.2.gem (100%) Fetching: jruby-rack-1.0.4.gem (100%) Fetching: jruby-jars-1.5.6.gem (100%) Fetching: appengine-rack-0.0.13.gem (100%) Fetching: appengine-apis-0.0.24.gem (100%) Fetching: appengine-sdk-1.4.3.gem (100%) Fetching: bundler08-0.8.5.gem (100%) Fetching: rubyzip-1.1.0.gem (100%) ERROR: Error installing google-appengine: rubyzip requires Ruby version >= 1.9.2.
見て分かる通り,google-appengineが依存するrubyzipはruby1.9.2を要求する.
どうもrubyzipは1.0以降で1.9.2以降のみのサポートになったらしい.
そこで1.0未満のrubyzipを入れる.
今回は0.9.5を入れた.(特に0.9.5にした意味は無い)
$ gem install rubyzip -v 0.9.5
これを行った上でならgoogle-appengineは問題なくインストールされる. また,このgemはrubygem1.3.7を要求するのでrubygemのダウングレードも行う.
$ gem update --system 1.3.7
これで動くはず.
その他過程で学んだこと
- 単体でインストールしたいとき(というよりは依存関係や動作環境を無視したい場合)は-fオプションを付ける
gem install -f gem_name
gem fetch gem_name
で.gem
ファイルがダウンロードされる,それのインストールはgem install -l gem_name.gem