在Mac OS High Sierra中,foodcritic(3.0.3)gem安装失败

时间:2018-07-29 11:58:54

标签: ruby rubygems yajl

我的食物评论家gem安装失败并出现以下错误

Following gems were not installed:
foodcritic (3.0.3): Error installing foodcritic
ERROR: Failed to build gem native extension. current directory
/Users/dmanna/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/yajl-ruby-1.1.0/ext/yajl
/Users/dmanna/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf/20180729-63637-1dtcegj.rb.extconf.rb creating Makefile current
directory: /Users/dmanna/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/yajl-ruby-1.1.0/ext/yajl make "DESTDIR=" clean current
directory: /Users/dmanna/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/yajl-ruby-1.1.0/ext/yajl make "DESTDIR=" compiling
yajl.c compiling yajl_alloc.c compiling yajl_buf.c compiling yajl_encode.c compiling yajl_ext.c yajl_ext.c:852:22 error: use of undeclared identifier 'rb_cFixnum' rb_define_method(rb_cFixnum, "to_json", rb_yajl_json_ext_fixnum_to_json, -1); ^ 1 error generated.

make: *** [yajl_ext.o] Error 1 make failed, exit code 2 Gem files remain installed in 
/Users/dmanna/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/yajl-ruby-1.1.0 for inspection. Results logged to
/Users/dmanna/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/yajl-ruby-1.1.0/gem_make.out

gem_make.out的输出

current directory: /Users/dmanna/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/yajl-ruby-1.1.0/ext/yajl
/Users/dmanna/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf20180729-63637-1dtcegj.rb extconf.rb
creating Makefile

current directory: /Users/dmanna/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/yajl-ruby-1.1.0/ext/yajl
make "DESTDIR=" clean

current directory: /Users/dmanna/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/yajl-ruby-1.1.0/ext/yajl
make "DESTDIR="
compiling yajl.c
compiling yajl_alloc.c
compiling yajl_buf.c
compiling yajl_encode.c
compiling yajl_ext.c
yajl_ext.c:852:22: error: use of undeclared identifier 'rb_cFixnum'
    rb_define_method(rb_cFixnum, "to_json", rb_yajl_json_ext_fixnum_to_json, -1);
                     ^
1 error generated.
make: *** [yajl_ext.o] Error 1

make failed, exit code 2
  • rbenv版本-2.5.1操作系统
  • Mac 10.13.6

我是红宝石的新手。尝试在RubyMine中导入项目并安装gem时出现此错误。

有人可以让我知道发生了什么问题以及如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

Foodcritic 3.0.3始于2013年。请参见此处:
https://rubygems.org/gems/foodcritic/versions/3.0.3

不幸的是,它与最新版本的Ruby不兼容。您可以选择将Ruby降级到2.4以下,甚至可以降到1.9以确保兼容性,或者将foodcritic升级到最新版本(14.0.0)。