Skip to content
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

Merged
merged 8 commits into from
Jun 17, 2023
Merged

Bring Back Rails 4.2 Support #32

merged 8 commits into from
Jun 17, 2023

Conversation

amatsuda
Copy link
Member

@amatsuda amatsuda commented Jun 16, 2023

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.

@@ -0,0 +1,26 @@
# -*- ruby -*-
#
# Copyright (C) 2023 Sutou Kouhei <[email protected]>
Copy link
Member

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? :-)

Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did so.

@@ -22,6 +22,7 @@ RUN \
rm -rf /var/lib/apt/lists/*

ARG RAILS_VERSION
RUN gem update --system 3.3.26
Copy link
Member

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.

Copy link
Member Author

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.

amatsuda added 6 commits June 17, 2023 12:53
/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.
@kou
Copy link
Member

kou commented Jun 17, 2023

Thanks!

@kou kou merged commit 5661799 into test-unit:master Jun 17, 2023
@amatsuda amatsuda deleted the rails42 branch June 18, 2023 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants