我想在 Ruby 2.4 上试用 Rails 4.2 应用程序。
但是,当我尝试这样做时,我收到有关 json gem 版本 1.8.3 无法安装的错误。
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/agrimm/.rbenv/versions/2.4.0-rc1/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
/Users/agrimm/.rbenv/versions/2.4.0-rc1/bin/ruby -r ./siteconf20161223-91367-cql0ne.rb extconf.rb
creating Makefile
current directory: /Users/agrimm/.rbenv/versions/2.4.0-rc1/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /Users/agrimm/.rbenv/versions/2.4.0-rc1/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
generator.c:861:25: error: use of undeclared identifier 'rb_cFixnum'
} else if (klass == rb_cFixnum) {
^
generator.c:863:25: error: use of undeclared identifier 'rb_cBignum'
} else if (klass == rb_cBignum) {
^
2 errors generated.
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/agrimm/.rbenv/versions/2.4.0-rc1/lib/ruby/gems/2.4.0/gems/json-1.8.3 for inspection.
Results logged to /Users/agrimm/.rbenv/versions/2.4.0-rc1/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-14/2.4.0-static/json-1.8.3/gem_make.out
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling.
我认为这是由于 Fixnum 和 Bignum 统一为 Integer。
如果我在 Gemfile 中添加 json 必须是 2.0.0 版本的约束,那么它会抱怨 Rails 4.2 需要 json ~> 1.7,它禁止 2.0.0。
除非 Rails 的维护者决定对 Rails 的非 5.x 版本进行更改,或者 json gem 的维护者决定为他们的 gem 制作一个新的非 2.x 版本,否则我会不走运吗?