是否可以在Ruby 2.4上运行Rails 4.2应用程序?

时间:2021-02-20 23:11:36

I want to try out a Rails 4.2 app on Ruby 2.4.

我想尝试一个关于Ruby 2.4的Rails 4.2应用程序。

However, when I try doing it, I get errors about the json gem version 1.8.3 failing to install.

但是,当我尝试这样做时,会发现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.

which I assume is due to the unification of Fixnum and Bignum into Integer.

我认为这是由于将Fixnum和Bignum合并为Integer。

If I add to the Gemfile a constraint that json has to be version 2.0.0, then it complains that Rails 4.2 requires json ~> 1.7, which forbids 2.0.0.

如果我向Gemfile添加一个约束,即json必须是2.0.0版本,那么它会抱怨Rails 4.2需要json ~> 1.7,这禁止2.0.0。

Am I out of luck unless the maintainers of Rails decide to make a change to a non-5.x version of Rails, or the maintainers of the json gem decide to make a new non-2.x version of their gem?

除非Rails的维护人员决定更改为非5,否则我就不走运了。x版本的Rails,或者json gem的维护者决定创建一个新的非2。x版的宝石?

4 个解决方案

#1


11  

It is now possible with rails 4.2.8.rc1 (February 11th 2017)

现在可以使用rails 4.2.8。rc1(2017年2月11日)

#2


16  

The json gem has a fix on the 1.8 branch. Hopefully it'll be released as a gem soon, but in the meantime you can use it directly in your Gemfile:

json gem在1.8分支上有一个补丁。希望它很快就会作为gem发布,但同时你也可以直接在Gemfile中使用:

gem 'json', github: 'flori/json', branch: 'v1.8'

Rails has also merged a fix to the 4-2-stable branch about a week after the latest official 4.2.x gem release. Hopefully they'll release a new gem soon too, but this might help in your Gemfile:

在最新的官方4.2版本发布大约一周后,Rails也将一个补丁合并到42稳定的分支上。x宝石。希望他们也会很快发布一个新的gem,但是这可能对您的Gemfile有所帮助:

gem 'rails', github: 'rails/rails', branch: '4-2-stable'

Finally, you may need to load arel from a git source as well:

最后,您可能还需要从git源加载arel:

gem 'arel', github: 'rails/arel', branch: '6-0-stable'

With those three changes I was able to boot our app and query the database, but then ran into other Integer unification related issues. Seems like this change to going to cause some waves.

通过这三个更改,我能够启动应用程序并查询数据库,但随后遇到了其他整数统一相关的问题。看起来这个变化会引起一些波动。

#3


5  

Upgrade rails to rails-4.2.8 .This is the first 4.2.x version that officially supports ruby-2.4

升级rails-4.2.8,这是第一个4.2版本。正式支持ruby-2.4的x版本

#4


4  

It looks like it won't be possible at the moment (Although it sounds odd).

现在看来这是不可能的(尽管听起来很奇怪)。

See the Changelog for the JSON gem. Json 2.0.0 adds compatibility for ruby 2.4, but rails 4.2 restricts json to 1.x

请参见JSON gem的Changelog。Json 2.0.0增加了ruby 2.4的兼容性,而rails 4.2将Json限制为1.x

#1


11  

It is now possible with rails 4.2.8.rc1 (February 11th 2017)

现在可以使用rails 4.2.8。rc1(2017年2月11日)

#2


16  

The json gem has a fix on the 1.8 branch. Hopefully it'll be released as a gem soon, but in the meantime you can use it directly in your Gemfile:

json gem在1.8分支上有一个补丁。希望它很快就会作为gem发布,但同时你也可以直接在Gemfile中使用:

gem 'json', github: 'flori/json', branch: 'v1.8'

Rails has also merged a fix to the 4-2-stable branch about a week after the latest official 4.2.x gem release. Hopefully they'll release a new gem soon too, but this might help in your Gemfile:

在最新的官方4.2版本发布大约一周后,Rails也将一个补丁合并到42稳定的分支上。x宝石。希望他们也会很快发布一个新的gem,但是这可能对您的Gemfile有所帮助:

gem 'rails', github: 'rails/rails', branch: '4-2-stable'

Finally, you may need to load arel from a git source as well:

最后,您可能还需要从git源加载arel:

gem 'arel', github: 'rails/arel', branch: '6-0-stable'

With those three changes I was able to boot our app and query the database, but then ran into other Integer unification related issues. Seems like this change to going to cause some waves.

通过这三个更改,我能够启动应用程序并查询数据库,但随后遇到了其他整数统一相关的问题。看起来这个变化会引起一些波动。

#3


5  

Upgrade rails to rails-4.2.8 .This is the first 4.2.x version that officially supports ruby-2.4

升级rails-4.2.8,这是第一个4.2版本。正式支持ruby-2.4的x版本

#4


4  

It looks like it won't be possible at the moment (Although it sounds odd).

现在看来这是不可能的(尽管听起来很奇怪)。

See the Changelog for the JSON gem. Json 2.0.0 adds compatibility for ruby 2.4, but rails 4.2 restricts json to 1.x

请参见JSON gem的Changelog。Json 2.0.0增加了ruby 2.4的兼容性,而rails 4.2将Json限制为1.x