问题描述
操作系统:Mac OS X 10.10.3 X代码:最新安装了命令行工具(6.3版)Rails:4.2.1版Ruby:2.2.1版
当我收到错误消息时,我正在尝试为我正在处理的项目生成路由(定期执行此操作),并建议我捆绑安装并捆绑exec.我这样做了,这一次,在编译JSON Gem(版本1.7.7)时,该过程中断了.
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).
对StackOverflow进行了一些研究,建议是更新Xcode的命令行工具,我这样做了,但这并不能解决问题.
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.
我尝试单独安装JSON 1.7.7版,但失败了,并告诉我要在以下位置查找错误日志:
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
推荐答案
不幸的是,JSON-1.7.7(以及最高1.8.1)是与Ruby-2.2.x不兼容.当您使用Ruby-2.2.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.
为您提供2种选择:
- 将您的
json
gem更新为1.8.2
版本. -首选 - 编辑
ruby-2.2.1/ext/json/fbuffer/fbuffer.h
文件,并用VALUE result = rb_str_new(FBUFFER_PTR(fb), FBUFFER_LEN(fb));
替换有问题的代码.详情请此处
- 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
这篇关于如何安装json gem-无法构建gem本机扩展(mac 10.10)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!