-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bring Back Rails 4.2 Support #32
Conversation
gemfiles/rails4.2.gemfile
Outdated
@@ -0,0 +1,26 @@ | |||
# -*- ruby -*- | |||
# | |||
# Copyright (C) 2023 Sutou Kouhei <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use your information for what you created? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
sed -i'' -e "s/gem 'sqlite3'/gem 'sqlite3', '~> 1.3.6'/" Gemfile | ||
fi | ||
if [[ "${RAILS_VERSION}" =~ ^4 ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment what you described in the PR description here too?
It'll be easy to refer on maintenance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did so.
dockerfiles/ruby.dockerfile
Outdated
@@ -22,6 +22,7 @@ RUN \ | |||
rm -rf /var/lib/apt/lists/* | |||
|
|||
ARG RAILS_VERSION | |||
RUN gem update --system 3.3.26 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment what you described in the PR description here too?
It'll be easy to refer on maintenance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the comment with a slight update on the code.
/usr/local/bundle/gems/loofah-2.21.1/lib/loofah/html4/document.rb:10:in `<module:HTML4>': uninitialized constant Nokogiri::HTML4 (NameError)
Rails 4 supports bundler < 2 only, and RubyGems 3.3 (that can install rails 4.2 gem) ships with bundler 2. And strangely, installing bundler 1.17.3 and calling it with `bundle _1.17.3_` doesn't work on this container. So we're bundling down RubyGems to the one that bundles Bundler 1.17.3.
Thanks! |
This patch brings Rails 4.2 support back.
Although no change inside
lib
directory is included this time, this patch contains a little bit tricky hacks in the script for the containers, in order for Ruby 2.4 to install and run Rails 4.2.The first hack is that we had to update rubygems because Ruby 2.4's default rubygems is too old that it fails to install rails 4.2 by not being able to resolve the gem dependencies. So we're updating the version of rubygems to 3.3.26, the latest version of 3.3.x that supports Ruby 2.4.
However, Rails 2.4 requires bundler 1.x in runtime, and so we have to install bundler 1 as well. I thought we could just
gem install bundler '<2'
(1.17.3 was the last release) and call it with rubygems' version specifier e.g.bundle _1.17.3_ install
, but strangely, this basic feature of rubygems didn't work on the container environment here for some unknown reason. So instead, I had to downgrade the versions of whole rubygems / bundler pair, this time to the one that includes bundler 1.17.3 i.e. rubygems 3.0.9 (rubygems 3.1.x ships with bundler 2).This is the whole story of why we're reinstalling different versions of rubygems here and there. Version 3.3 is needed to install rails 4.2, and 3.0 is needed to run it. This is, I guess, the trickiest part of this patch, and the rest is just needed to properly run and pass the tests.