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

Ruby2.2以降でjson gem 1.8.1がインストールできない件の対応

Ruby Rails

結論

json 1.8.2以降を使用する


上記IssueでRuby2.2対応は1.8.2含まれたことがわかる。

表示されるエラー

恐らくrb_new_strの引数の数が変わった為エラーになっていると推測するが、Ruby2.2から変更になったという確かなソースはまだ見つけていない。

Installing json 1.8.1 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/username/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/json-1.8.1/ext/json/ext/generator
/Users/username/.rbenv/versions/2.3.0/bin/ruby -r ./siteconf20160418-10435-3lhwvh.rb extconf.rb
creating Makefile

current directory: /Users/username/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/json-1.8.1/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /Users/username/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/json-1.8.1/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:
./../fbuffer/fbuffer.h:175:47: error: too few arguments provided to function-like macro invocation
    VALUE result = rb_str_new(FBUFFER_PAIR(fb));
                                              ^
/Users/username/.rbenv/versions/2.3.0/include/ruby-2.3.0/ruby/intern.h:797:9: note: macro 'rb_str_new' defined here
#define rb_str_new(str, len) __extension__ (    \
        ^
In file included from generator.c:1:
./../fbuffer/fbuffer.h:175:11: warning: incompatible pointer to integer conversion initializing 'VALUE' (aka 'unsigned long') with an expression of type 'VALUE (const char *, long)' (aka 'unsigned long (const char *, long)') [-Wint-conversion]
    VALUE result = rb_str_new(FBUFFER_PAIR(fb));
          ^        ~~~~~~~~~~
1 warning and 1 error generated.
make: *** [generator.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/username/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/json-1.8.1 for inspection.
Results logged to /Users/username/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/json-1.8.1/gem_make.out