Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
728 views
in Technique[技术] by (71.8m points)

ruby on rails - How to install json gem - Failed to build gem native extension(mac 10.10)

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:

  1. Update your json gem to 1.8.2 version. -- Preferable
  2. Edit ruby-2.2.1/ext/json/fbuffer/fbuffer.h file and replace problematic code with VALUE result = rb_str_new(FBUFFER_PTR(fb), FBUFFER_LEN(fb));. Look here for details

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...