Skip to content

Fix Rails 7 build #2523

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

Merged
merged 8 commits into from
Oct 2, 2021
Merged

Fix Rails 7 build #2523

merged 8 commits into from
Oct 2, 2021

Conversation

pirj
Copy link
Member

@pirj pirj commented Oct 1, 2021

This change:

  1. Removes explicit dependencies on gems independent, but required by Rails (i18n, rack)
  2. Removes explicit dependencies on Rails-swallowed gems (journey, arel)
  3. Minor fixes to tmp/example_app/Gemfile generation to avoid conflicts with Gemfile-rails-dependencies
  4. Added sprockets manifest generation

These changes only affect our build, and only against Rails' main.
See #2521 (comment) and https://github.com/rspec/rspec-rails/pull/2521/checks?check_run_id=3757830550

rack

Using rack from git opens up opportunities to fail due to unreleased rack issues, e.g. rack/rack#1768

No need to explicitly depend on rack, Rails does that: https://github.com/rails/rails/blob/c2b083df913f44e664576aafe24c41ec657f8eb5/actionpack/actionpack.gemspec#L37

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

journey

https://github.com/rails/journey

This gem was merged on Rails 4.0 and will only receive security fixes

arel

https://github.com/rails/arel

Arel was swallowed by Rails back in 2018

pirj added 4 commits October 1, 2021 20:35
Using rack from git opens up opportunities to fail due to unreleased
rack issues, e.g. rack/rack#1768

No need to explicitly depend on rack, Rails does that https://github.com/rails/rails/blob/c2b083df913f44e664576aafe24c41ec657f8eb5/actionpack/actionpack.gemspec#L37
Arel was swallowed by Rails back in 2018
> This gem was merged on Rails 4.0 and will only receive security fixes
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
@pirj pirj self-assigned this Oct 1, 2021
pirj added 3 commits October 1, 2021 21:13
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'
 #  -------------------------------------------
```
```
gem "debug", ">= 1.0.0", platforms: %i[ mri mingw x64_mingw ]
```
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'
 #  -------------------------------------------
```
@pirj pirj force-pushed the fix-rails-7-build branch 2 times, most recently from 28a5aa4 to 81196dd Compare October 1, 2021 19:36
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
```
@pirj pirj force-pushed the fix-rails-7-build branch from 81196dd to acaa4f3 Compare October 1, 2021 19:48
@pirj pirj requested review from JonRowe and benoittgt October 1, 2021 19:55
@pirj pirj changed the title Remove explicit dependencies on gems Fix Rails 7 build Oct 1, 2021
@JonRowe
Copy link
Member

JonRowe commented Oct 1, 2021

Removing mainline dependencies on arel and journey is fine, as the Rails mainline has since swallowed them; rack and i18n is a bit more hand-wavey, they are there as previous mainline versions of rails have relied on unreleased versions, we can remove them for now but we might have to add them back in future. Feel free to merge with that in mind.

@pirj pirj merged commit 969a5b2 into main Oct 2, 2021
@pirj pirj deleted the fix-rails-7-build branch October 2, 2021 18:50
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