西澤さま: 松葉です.
最新版をソースからインストールしてみたのですが,状況が改善しません.
それどころかエラーが出る場所が変わって,initialize の時点でエラーが出ます.
$ ruby test_varnames.rb
GRIB_API ERROR : grib_parser: syntax error at line 14 of /usr/local/share/grib_api/definitions/boot.def
GRIB_API ERROR : grib_handle_new_from_message: cannot create handle, no definitions found
/var/lib/gems/2.1.0/gems/rb-grib-0.3.0/lib/numru/grib/grib.rb:20: [BUG] Segmentation fault at 0x00000000000000
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
-- Control frame information -----------------------------------------------
c:0007 p:---- s:0033 e:000032 CFUNC :initialize
c:0006 p:---- s:0031 e:000030 CFUNC :new
c:0005 p:0066 s:0026 e:000025 METHOD /var/lib/gems/2.1.0/gems/rb-grib-0.3.0/lib/numru/grib/grib.rb:20
c:0004 p:0072 s:0018 e:000017 METHOD /usr/lib/ruby/vendor_ruby/numru/gphys/gphys_grib_io.rb:160
c:0003 p:0013 s:0012 e:000011 METHOD /usr/lib/ruby/vendor_ruby/numru/gphys/gphys_io.rb:372
c:0002 p:0065 s:0008 E:001e30 EVAL test_varnames.rb:9 [FINISH]
c:0001 p:0000 s:0002 E:000378 TOP [FINISH]
-- Ruby level backtrace information ----------------------------------------
test_varnames.rb:9:in `<main>'
/usr/lib/ruby/vendor_ruby/numru/gphys/gphys_io.rb:372:in `var_names'
/usr/lib/ruby/vendor_ruby/numru/gphys/gphys_grib_io.rb:160:in `var_names'
/var/lib/gems/2.1.0/gems/rb-grib-0.3.0/lib/numru/grib/grib.rb:20:in `new'
/var/lib/gems/2.1.0/gems/rb-grib-0.3.0/lib/numru/grib/grib.rb:20:in `new'
/var/lib/gems/2.1.0/gems/rb-grib-0.3.0/lib/numru/grib/grib.rb:20:in `initialize'
-- C level backtrace information -------------------------------------------
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(+0x18a837) [0x7fc57af6b837]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(+0x18a903) [0x7fc57af6b903]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(+0x6d563) [0x7fc57ae4e563]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(rb_bug+0xb3) [0x7fc57ae4ebd3]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(+0x12144f) [0x7fc57af0244f]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xf8d0) [0x7fc57abd38d0]
/var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/rb-grib-0.3.0/numru/grib.so(+0x29d9) [0x7fc574cb19d9] grib.c:407
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(+0x1770c6) [0x7fc57af580c6]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(rb_funcallv+0x159) [0x7fc57af5c239]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(rb_class_new_instance+0x21) [0x7fc57aea02b1]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(+0x174ee6) [0x7fc57af55ee6]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(+0x1856ad) [0x7fc57af666ad]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(+0x17dd23) [0x7fc57af5ed23]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(+0x1835ed) [0x7fc57af645ed]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(rb_iseq_eval_main+0x7f) [0x7fc57af663cf]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(+0x70c3f) [0x7fc57ae51c3f]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(ruby_exec_node+0x1d) [0x7fc57ae5360d]
/usr/lib/x86_64-linux-gnu/libruby-2.1.so.2.1(ruby_run_node+0x1e) [0x7fc57ae5532e]
ruby() [0x4008ab]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7fc579e7bb45]
ruby() [0x4008d9]
-- Other runtime information -----------------------------------------------
何か手順を間違えているのでしょうか.
一応,どういうコマンドを打ったのかメモしておきます.
GRIB API 最新版をインストールする手順:
$ tar zxvf grib_api-1.15.0-Source.tar.gz
$ cd grib_api-1.15.0-Source
$ ./configure -prefix=/usr/local
$ make
$ make check # ここですべてのチェックをクリア
$ sudo make install
.bashrc に以下を追加:
$ emacs -nw ~/.bashrc
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}
$ source ~/.bashrc
rb-grib を再度インストール
$ sudo gem uninstall rb-grib
$ sudo gem install rb-grib
スクリプトを実行してみた結果
$ ruby test_varnames.rb #=> Segmentation fault
rb-grib のバージョンを下げることで回避しようと考えたのですが,こちらも嵌ってます.
バージョン 0.2.2 を gem install しようとすると以下のエラーが出ます.
$ sudo gem install rb-grib -v 0.2.2
Building native extensions. This could take a while...
ERROR: Error installing rb-grib:
ERROR: Failed to build gem native extension.
/usr/bin/ruby2.1 extconf.rb
checking for narray.h in /usr/lib/x86_64-linux-gnu/ruby/vendor_ruby/2.1.0,$(rubyarchdir),./.gem.20160624-23606-1oi0wb,$(rubysitearchprefix)/vendor_ruby/$(ruby_version)... yes
checking for grib_api.h... yes
checking for main() in -lgrib_api... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling grib.c
grib.c: In function ‘check_error’:
grib.c:14:3: error: format not a string literal and no format arguments [-Werror=format-security]
if (code) rb_raise(rb_eRuntimeError, grib_get_error_message(code));
^
cc1: some warnings being treated as errors
Makefile:224: recipe for target 'grib.o' failed
make: *** [grib.o] Error 1
make failed, exit code 2
Gem files will remain installed in /var/lib/gems/2.1.0/gems/rb-grib-0.2.2 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/rb-grib-0.2.2/gem_make.out
念のためですが,こちらの ruby のバージョンは 2.1.5 となってます.
$ ruby -v
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]