From 1bd603cb6a2d6b92dc2db0b56040cc6b73f0a7b7 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Fri, 1 Oct 2021 20:35:20 +0300 Subject: [PATCH 1/8] Remove explicit dependency on rack for our build Using rack from git opens up opportunities to fail due to unreleased rack issues, e.g. https://github.com/rack/rack/issues/1768 No need to explicitly depend on rack, Rails does that https://github.com/rails/rails/blob/c2b083df913f44e664576aafe24c41ec657f8eb5/actionpack/actionpack.gemspec#L37 --- Gemfile-rails-dependencies | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile-rails-dependencies b/Gemfile-rails-dependencies index 9478abaf8..afdd21d07 100644 --- a/Gemfile-rails-dependencies +++ b/Gemfile-rails-dependencies @@ -8,7 +8,6 @@ when /master/ gem "activerecord-deprecated_finders", :git => "https://github.com/rails/activerecord-deprecated_finders.git" gem "web-console", :git => "https://github.com/rails/web-console", :group => :development gem 'coffee-rails', :git => "https://github.com/rails/coffee-rails.git" - gem 'rack', :git => 'https://github.com/rack/rack.git' gem 'i18n', :git => 'https://github.com/svenfuchs/i18n.git', :branch => 'master' gem 'sprockets', :git => 'https://github.com/rails/sprockets.git', :branch => 'master' gem 'sprockets-rails', :git => 'https://github.com/rails/sprockets-rails.git', :branch => 'master' From f71a2d96d29ab285d55885ff0ae88915e31633ae Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Fri, 1 Oct 2021 20:38:51 +0300 Subject: [PATCH 2/8] Remove explicit arel dependency Arel was swallowed by Rails back in 2018 --- Gemfile-rails-dependencies | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile-rails-dependencies b/Gemfile-rails-dependencies index afdd21d07..d4c3eb22a 100644 --- a/Gemfile-rails-dependencies +++ b/Gemfile-rails-dependencies @@ -3,7 +3,6 @@ version_file = File.expand_path("../.rails-version", __FILE__) case version = ENV['RAILS_VERSION'] || (File.exist?(version_file) && File.read(version_file).chomp) || '' when /master/ gem "rails", :git => "https://github.com/rails/rails.git" - gem "arel", :git => "https://github.com/rails/arel.git" gem "journey", :git => "https://github.com/rails/journey.git" gem "activerecord-deprecated_finders", :git => "https://github.com/rails/activerecord-deprecated_finders.git" gem "web-console", :git => "https://github.com/rails/web-console", :group => :development From 045bfc99b5f1864eff170b04b7529af7afe7330f Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Fri, 1 Oct 2021 20:41:39 +0300 Subject: [PATCH 3/8] Remove explicit dependency on journey > This gem was merged on Rails 4.0 and will only receive security fixes --- Gemfile-rails-dependencies | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile-rails-dependencies b/Gemfile-rails-dependencies index d4c3eb22a..99045f5c6 100644 --- a/Gemfile-rails-dependencies +++ b/Gemfile-rails-dependencies @@ -3,7 +3,6 @@ version_file = File.expand_path("../.rails-version", __FILE__) case version = ENV['RAILS_VERSION'] || (File.exist?(version_file) && File.read(version_file).chomp) || '' when /master/ gem "rails", :git => "https://github.com/rails/rails.git" - gem "journey", :git => "https://github.com/rails/journey.git" gem "activerecord-deprecated_finders", :git => "https://github.com/rails/activerecord-deprecated_finders.git" gem "web-console", :git => "https://github.com/rails/web-console", :group => :development gem 'coffee-rails', :git => "https://github.com/rails/coffee-rails.git" From a1061e6261c4da925964f5e52865d92a4756c77d Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Fri, 1 Oct 2021 20:44:09 +0300 Subject: [PATCH 4/8] Remove explicit dependency on i18n Depending on i18n's latest git version opens up opportunities to: 1. fail due to i18n's unstable changes 2. fail due to version conflict (their `master` can flip to 2.0, while `rails` would depend on `< 2`) Rails explicitly depend on `i18n` anyway: https://github.com/rails/rails/blob/c2b083df913f44e664576aafe24c41ec657f8eb5/activesupport/activesupport.gemspec#L36 --- Gemfile-rails-dependencies | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile-rails-dependencies b/Gemfile-rails-dependencies index 99045f5c6..04b4a0085 100644 --- a/Gemfile-rails-dependencies +++ b/Gemfile-rails-dependencies @@ -6,7 +6,6 @@ when /master/ gem "activerecord-deprecated_finders", :git => "https://github.com/rails/activerecord-deprecated_finders.git" gem "web-console", :git => "https://github.com/rails/web-console", :group => :development gem 'coffee-rails', :git => "https://github.com/rails/coffee-rails.git" - gem 'i18n', :git => 'https://github.com/svenfuchs/i18n.git', :branch => 'master' gem 'sprockets', :git => 'https://github.com/rails/sprockets.git', :branch => 'master' gem 'sprockets-rails', :git => 'https://github.com/rails/sprockets-rails.git', :branch => 'master' gem 'puma', "3.12.1" From 6a55a6be5e01d1f9007ac36f0f269ee027140e42 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Fri, 1 Oct 2021 21:13:55 +0300 Subject: [PATCH 5/8] Adjust removal of `rails` from example app Gemfile Rails went with double quotes: ```ruby gem "rails", "~> 7.0.0.alpha2" ``` and this was causing Bundler to complain: ``` [!] There was an error parsing `Gemfile`: [!] There was an error parsing `Gemfile-rails-dependencies`: You cannot specify the same gem twice with different version requirements. You specified: rails (~> 7.0.0.alpha2) and rails (>= 0). Bundler cannot continue. # from /Users/pirj/source/rspec-dev/repos/rspec-rails/Gemfile-rails-dependencies:5 # ------------------------------------------- # when /master/ > gem "rails", :git => "https://github.com/rails/rails.git" # gem "activerecord-deprecated_finders", :git => "https://github.com/rails/activerecord-deprecated_finders.git" # ------------------------------------------- . Bundler cannot continue. # from /Users/pirj/source/rspec-dev/repos/rspec-rails/tmp/example_app/Gemfile:63 # ------------------------------------------- # eval_gemfile '/Users/pirj/source/rspec-dev/repos/rspec-rails/Gemfile-rspec-dependencies' > eval_gemfile '/Users/pirj/source/rspec-dev/repos/rspec-rails/Gemfile-rails-dependencies' # ------------------------------------------- ``` --- example_app_generator/generate_app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example_app_generator/generate_app.rb b/example_app_generator/generate_app.rb index 1cc56f5b6..45c9ad257 100644 --- a/example_app_generator/generate_app.rb +++ b/example_app_generator/generate_app.rb @@ -18,7 +18,7 @@ # Remove the existing rails version so we can properly use main or other # edge branches - gsub_file 'Gemfile', /^.*\bgem 'rails.*$/, '' + gsub_file 'Gemfile', /^.*\bgem ['"]rails.*$/, '' gsub_file "Gemfile", /.*web-console.*/, '' gsub_file "Gemfile", /.*debugger.*/, '' gsub_file "Gemfile", /.*puma.*/, '' From c034af30d9d6449d95d00acf1eacbb22e85721d2 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Fri, 1 Oct 2021 21:22:20 +0300 Subject: [PATCH 6/8] Also remove the newly introduced `debug` gem ``` gem "debug", ">= 1.0.0", platforms: %i[ mri mingw x64_mingw ] ``` --- example_app_generator/generate_app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example_app_generator/generate_app.rb b/example_app_generator/generate_app.rb index 45c9ad257..096869ada 100644 --- a/example_app_generator/generate_app.rb +++ b/example_app_generator/generate_app.rb @@ -20,7 +20,7 @@ # edge branches gsub_file 'Gemfile', /^.*\bgem ['"]rails.*$/, '' gsub_file "Gemfile", /.*web-console.*/, '' - gsub_file "Gemfile", /.*debugger.*/, '' + gsub_file "Gemfile", /.*debug.*/, '' gsub_file "Gemfile", /.*puma.*/, '' gsub_file "Gemfile", /.*bootsnap.*/, '' From af7d012694ee6013768bbc1f9402b829d8c49af5 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Fri, 1 Oct 2021 21:26:00 +0300 Subject: [PATCH 7/8] Also remove selenium-webdriver from example app It conflicts with the one from `Gemfile-rails-dependencies` ``` [!] There was an error parsing `Gemfile`: [!] There was an error parsing `Gemfile-rails-dependencies`: You cannot specify the same gem twice with different version requirements. You specified: selenium-webdriver (>= 4.0.0.rc1) and selenium-webdriver (>= 0). Bundler cannot continue. # from /Users/pirj/source/rspec-dev/repos/rspec-rails/Gemfile-rails-dependencies:13 # ------------------------------------------- # gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', platforms: [:jruby] > gem 'selenium-webdriver', require: false # when /stable$/ # ------------------------------------------- . Bundler cannot continue. # from /Users/pirj/source/rspec-dev/repos/rspec-rails/tmp/example_app/Gemfile:63 # ------------------------------------------- # eval_gemfile '/Users/pirj/source/rspec-dev/repos/rspec-rails/Gemfile-rspec-dependencies' > eval_gemfile '/Users/pirj/source/rspec-dev/repos/rspec-rails/Gemfile-rails-dependencies' # ------------------------------------------- ``` --- example_app_generator/generate_app.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/example_app_generator/generate_app.rb b/example_app_generator/generate_app.rb index 096869ada..df704da41 100644 --- a/example_app_generator/generate_app.rb +++ b/example_app_generator/generate_app.rb @@ -19,6 +19,7 @@ # Remove the existing rails version so we can properly use main or other # edge branches gsub_file 'Gemfile', /^.*\bgem ['"]rails.*$/, '' + gsub_file 'Gemfile', /^.*\bgem ['"]selenium\-webdriver.*$/, '' gsub_file "Gemfile", /.*web-console.*/, '' gsub_file "Gemfile", /.*debug.*/, '' gsub_file "Gemfile", /.*puma.*/, '' From acaa4f321e4d55aab769c12ad3afc9fac7201ff1 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Fri, 1 Oct 2021 22:07:58 +0300 Subject: [PATCH 8/8] Create sprockets manifest for example app https://github.com/rails/sprockets/blob/070fc01947c111d35bb4c836e9bb71962a8e0595/UPGRADING.md#manifestjs Otherwise ``` ** Invoke generate:stuff (first_time) ** Execute generate:stuff bin/rake app:template LOCATION='../../example_app_generator/generate_stuff.rb' rake aborted! Sprockets::Railtie::ManifestNeededError: Expected to find a manifest file in `app/assets/config/manifest.js` But did not, please create this file and use it to link any assets that need to be rendered by your app: Example: //= link_tree ../images //= link_directory ../javascripts .js //= link_directory ../stylesheets .css and restart your server ``` This, however, fails on Rails < 7: ``` # --- Caused by: --- # Sprockets::Rails::Helper::AssetNotPrecompiled: # application.css ``` Without `application.css`: ``` Failure/Error: <%= stylesheet_link_tag "application" %> ActionView::Template::Error: The asset "application.css" is not present in the asset pipeline. ``` Without content in `manifest.js`: ``` Failures: 1) Welcomes GET /index returns http success Failure/Error: <%= stylesheet_link_tag "application" %> ActionView::Template::Error: Asset `application.css` was not declared to be precompiled in production. Declare links to your assets in `app/assets/config/manifest.js`. //= link application.css ``` --- example_app_generator/generate_app.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/example_app_generator/generate_app.rb b/example_app_generator/generate_app.rb index df704da41..08ecbf2f6 100644 --- a/example_app_generator/generate_app.rb +++ b/example_app_generator/generate_app.rb @@ -78,4 +78,11 @@ 'REPLACE_BUNDLE_PATH', bundle_install_path chmod 'ci_retry_bundle_install.sh', 0755 + + if Rails::VERSION::STRING > '7' + create_file 'app/assets/config/manifest.js' do + "//= link application.css" + end + create_file 'app/assets/stylesheets/application.css' + end end