How to install json gem - Failed to build gem native extension(mac 10.10)
Solution 1
Sad, however, JSON-1.7.7 (and upto 1.8.1) is incompatible with Ruby-2.2.x. As you are using Ruby-2.2.1, it will not work for you.
There are 2 options for you:
- Update your
json
gem to1.8.2
version. -- Preferable - Edit
ruby-2.2.1/ext/json/fbuffer/fbuffer.h
file and replace problematic code withVALUE result = rb_str_new(FBUFFER_PTR(fb), FBUFFER_LEN(fb));
. Look here for details
Solution 2
If you are using Ruby 2.2.0 or greater, the json gem will not compile properly. You can fix this by issuing bundle update json
zwb
Updated on April 08, 2021Comments
-
zwb about 3 years
OS: Mac OS X 10.10.3 XCode: Latest with command line tools installed (version 6.3) Rails: version 4.2.1 Ruby: version 2.2.1
I was trying to generate the routes for a project I am working on (been doing that on regular basis), when I got an error message, with a recommendation that I do bundle install and bundle exec. I did, and this time around, the process broke off while compiling the JSON Gem (version 1.7.7).
Doing some research on StackOverflow, the recommendation was to update the Xcode's command line tools, and I did, but that did not solve the problem.
I tried installing the JSON version 1.7.7 separately, and it failed, telling me to look for the error log in:
/Users/zwb/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150411-36070-1t083xl.rb extconf.rb creating Makefile make "DESTDIR=" clean 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/zwb/.rvm/rubies/ruby-2.2.1/include/ruby-2.2.0/ruby/intern.h:793: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)' [-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