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

tohokuaikiのチラシの裏

技術的ネタとか。

Confluenceのプラグイン開発を承ります。ご連絡はこちらのホームページからお願いいたします。

milkodeのWindows8へのインストールでハマっている件

コード検索をfind&grepでやらなくても済むmilkodeというソフトがあります。

Rubyで書かれたWEBアプリなのでgemで簡単インストール。・・・・なのですが、ハマってます。以前インストールした際はそうでもなかったのですが、2年ぶりくらいにインストールしたらハマりました。

Rubyのインストール

FAQによると推奨バージョンがruby 1.9.3p392/2.0.0p0ということでRubyInstallerから1.9.3をインストール。Powershellなどで使えるようにRubyへのパスを環境変数PATHに追加。

PS C:\Users\Takashi> ruby -v
ruby 1.9.3p551 (2014-11-13) [i386-mingw32]

ついでに Devkitもインストールしておく。

gemでmilkodeのインストール

gemで簡単にインストールする。document関連のエラーが出るのが面倒なので-no-docをつける。たくさんの依存パッケージと共にインストールされる。

PS C:\Users\Takashi> gem install -no-doc milkode
Successfully installed milkode-1.8.8
1 gem installed

だけど、milkコマンドでエラーが出る。

PS C:\Users\Takashi> milk
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- groonga.so (LoadError)
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rroonga-6.0.0-x86-mingw32/lib/groonga.rb:46:in `rescue in <top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rroonga-6.0.0-x86-mingw32/lib/groonga.rb:42:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/milkode-1.8.8/lib/milkode/database/groonga_database.rb:9:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/milkode-1.8.8/lib/milkode/cdstk/cdstk.rb:24:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/milkode-1.8.8/lib/milkode/cli.rb:4:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/milkode-1.8.8/bin/milk:7:in `<top (required)>'
        from C:/Ruby193/bin/milk:23:in `load'
        from C:/Ruby193/bin/milk:23:in `<main>'

groonga.soができてないということで怒られる。

んー、っということでcygwinで検索してみる。

Takashi@JUNOE-VAIOPRO13 ~
$ cd /cygdrive/c/Ruby193/lib
$ find . -name "groonga.so"|xargs ls -lh
-rwxrwx---+ 1 Takashi なし 384K 5月   2 19:49 ./ruby/gems/1.9.1/gems/rroonga-6.0.0-x86-mingw32/lib/2.1/groonga.so
-rwxrwx---+ 1 Takashi なし 384K 5月   2 19:49 ./ruby/gems/1.9.1/gems/rroonga-6.0.0-x86-mingw32/lib/2.2/groonga.so
-rwxrwx---+ 1 Takashi なし 384K 5月   2 19:49 ./ruby/gems/1.9.1/gems/rroonga-6.0.0-x86-mingw32/lib/2.3/groonga.so

なんかgroonga.soが既にあるような気がする。。。

rroonga単体でインストールしてみる。

PS C:\Users\Takashi> gem install rroonga
Successfully installed rroonga-6.0.0-x86-mingw32
1 gem installed

インストールできたっぽいが、milkコマンド実行してもダメ。前と同じエラー。

devkitの説明ページを見てみると、gemインストール時にオプションが必要みたい。 ということで、--platform=rubyをつけてみる。前と様子が変わる。

PS C:\Users\Takashi> gem install rroonga --platform=ruby
Fetching: rroonga-6.0.0.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rroonga:
        ERROR: Failed to build gem native extension.

        C:/Ruby193/bin/ruby.exe extconf.rb
checking for GCC... yes
checking for Win32 OS... yes
downloading http://packages.groonga.org/windows/groonga/groonga-6.0.0-x86.zip... done
extracting... done
installing... done
removing binary archive... done
checking for groonga version (>= 6.0.0)... yes
checking for -Wl,-rpath is available... yes
checking for HAVE_RUBY_ST_H in ruby.h... yes
checking for rb_errinfo() in ruby.h... yes
checking for rb_sym2str() in ruby.h... no
checking for rb_to_symbol() in ruby.h... no
checking for rb_ary_new_from_args() in ruby.h... no
checking for rb_ary_new_from_values() in ruby.h... no
checking for enum ruby_value_type in ruby.h... yes
checking for --enable-debug-log option... no
checking for --enable-debug-build option... no
checking for --enable-untyped-data-warning option... no
creating Makefile

make
compiling rb-grn-accessor.c
compiling rb-grn-array-cursor.c
compiling rb-grn-array.c
compiling rb-grn-column.c
rb-grn-column.c: In function 'rb_grn_column_find_indexes':
rb-grn-column.c:769:5: warning: implicit declaration of function 'rb_ary_new_capa'
compiling rb-grn-config.c
compiling rb-grn-context.c
compiling rb-grn-database.c
compiling rb-grn-double-array-trie-cursor.c
compiling rb-grn-double-array-trie.c
compiling rb-grn-encoding-support.c
compiling rb-grn-encoding.c
compiling rb-grn-equal-operator.c
compiling rb-grn-exception.c
compiling rb-grn-expression-builder.c
compiling rb-grn-expression.c
compiling rb-grn-fix-size-column.c
compiling rb-grn-flushable.c
compiling rb-grn-geo-point.c
compiling rb-grn-greater-equal-operator.c
compiling rb-grn-greater-operator.c
compiling rb-grn-hash-cursor.c
compiling rb-grn-hash.c
compiling rb-grn-index-column.c
compiling rb-grn-index-cursor.c
compiling rb-grn-index.c
compiling rb-grn-less-equal-operator.c
compiling rb-grn-less-operator.c
compiling rb-grn-logger.c
compiling rb-grn-match-operator.c
compiling rb-grn-normalizer.c
compiling rb-grn-not-equal-operator.c
compiling rb-grn-object.c
rb-grn-object.c: In function 'rb_grn_object_key_accessor_p':
rb-grn-object.c:1707:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1708:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_accessor_p':
rb-grn-object.c:1671:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1672:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_scorer_procedure_p':
rb-grn-object.c:1645:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1646:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_selector_only_procedure_p':
rb-grn-object.c:1619:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1620:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_selector_procedure_p':
rb-grn-object.c:1593:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1594:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_function_procedure_p':
rb-grn-object.c:1567:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1568:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_procedure_p':
rb-grn-object.c:1541:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1542:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_table_p':
rb-grn-object.c:1516:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1517:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_builtin_p':
rb-grn-object.c:1491:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:1492:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_unlink':
rb-grn-object.c:626:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c:627:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c: In function 'rb_grn_object_close':
rb-grn-object.c:585:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c:585:14: note: 'object' was declared here
rb-grn-object.c:586:14: warning: 'context' may be used uninitialized in this function
rb-grn-object.c:586:14: note: 'context' was declared here
rb-grn-object.c: In function 'rb_grn_object_close_raw':
rb-grn-object.c:585:14: warning: 'object' may be used uninitialized in this function
rb-grn-object.c:586:14: warning: 'context' may be used uninitialized in this function
compiling rb-grn-operator.c
compiling rb-grn-patricia-trie-cursor.c
compiling rb-grn-patricia-trie.c
compiling rb-grn-plugin.c
compiling rb-grn-posting.c
compiling rb-grn-prefix-operator.c
compiling rb-grn-procedure-type.c
compiling rb-grn-procedure.c
compiling rb-grn-query-logger.c
compiling rb-grn-record.c
compiling rb-grn-regexp-operator.c
compiling rb-grn-snippet.c
compiling rb-grn-table-cursor-key-support.c
compiling rb-grn-table-cursor.c
compiling rb-grn-table-key-support.c
compiling rb-grn-table.c
compiling rb-grn-thread.c
compiling rb-grn-type.c
compiling rb-grn-utils.c
compiling rb-grn-variable-size-column.c
compiling rb-grn-variable.c
compiling rb-grn-windows-event-logger.c
compiling rb-groonga.c
rb-groonga.c: In function 'rb_grn_s_get_error_message':
rb-groonga.c:49:9: warning: implicit declaration of function 'rb_enc_str_new_cstr'
linking shared-object groonga.so
Creating library file: libruby-groonga.arb-grn-column.o: In function `rb_grn_column_find_indexes':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\rroonga-6.0.0\ext\groonga/rb-grn-column.c:769: undefined reference to `rb_ary_new_capa'rb-groonga.o: In function `rb_grn_s_get_error_message':
C:\Ruby193\lib\ruby\gems\1.9.1\gems\rroonga-6.0.0\ext\groonga/rb-groonga.c:49: undefined reference to `rb_enc_str_new_cstr'collect2: ld returned 1 exit status
make: *** [groonga.so] Error 1


Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/rroonga-6.0.0 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/rroonga-6.0.0/ext/groonga/gem_make.out

んー、groongaのコンパイルに失敗しているくさい。。。

groongaは単体でインストールできるので、Windowsインストーラをダウンロードしてインストールしてみる。こんなん普通に考えてパス通らないんじゃないかと思うんだけど、果たしてその通り何も変わらなかった。

というところでハマり。

対応策

Twitterで教えてもらった。

Ruby2.3にしたら問題なくgemでインストール完了。 なんて楽なんだ・・・・。@ktouさんありがとうございます。