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

Rails no longer recommends Spring by default. Let's remove it #3231

Merged
merged 7 commits into from
Sep 22, 2023

Conversation

murny
Copy link
Contributor

@murny murny commented Sep 15, 2023

Context

Spring is no longer recommended for smaller to medium-sized apps. It is also no longer a default gem in Rails. We can probably remove this, before we start work on Rails 7 upgrade.

More info: rails/rails#42997

As DHH says it probably causes more problems than its worth and the upsides of having it is quite minor.

One big issue is it breaks SimpleCov statistics when running tests.

Some additional context can be found here from an old PR which documents some of the savings we were seeing with Spring and more context around Spring in general in Jupiter: #1926

@murny murny marked this pull request as ready for review September 19, 2023 00:21
Copy link
Member

@pgwillia pgwillia left a comment

Choose a reason for hiding this comment

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

Something about this change makes starting the rails server in my development environment not possible.

$ git bisect bad
5b0279c3b5aab6cf556c91d75e3b09f8c832d1f4 is the first bad commit
commit 5b0279c3b5aab6cf556c91d75e3b09f8c832d1f4
Author: Shane Murnaghan <[email protected]>
Date:   Fri Sep 15 14:18:15 2023 -0600

    Rails no longer recommends Spring, lets remove it

 .github/workflows/push.yml |  1 -
 Gemfile                    |  4 ----
 Gemfile.lock               | 13 -------------
 bin/rails                  |  5 -----
 bin/rake                   |  5 -----
 bin/spring                 | 15 ---------------
 config/spring.rb           |  6 ------
 7 files changed, 49 deletions(-)
 delete mode 100755 bin/spring
 delete mode 100644 config/spring.rb

Here's the error message

$ bundle exec rails s
=> Booting Puma
=> Rails 6.1.7.6 application starting in development 
=> Run `bin/rails server --help` for more startup options
Exiting
/home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require': cannot load such file -- listen (LoadError)
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:in `block in require'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:299:in `load_dependency'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:in `require'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/evented_file_update_checker.rb:6:in `<main>'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:in `block in require'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:299:in `load_dependency'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:in `require'
        from /home/tricia/Code/jupiter/config/environments/development.rb:74:in `block in <main>'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/railtie.rb:234:in `instance_eval'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/railtie.rb:234:in `configure'
        from /home/tricia/Code/jupiter/config/environments/development.rb:5:in `<main>'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:in `block in require'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:299:in `load_dependency'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:in `require'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/engine.rb:571:in `block (2 levels) in <class:Engine>'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/engine.rb:570:in `each'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/engine.rb:570:in `block in <class:Engine>'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/initializable.rb:32:in `instance_exec'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/initializable.rb:32:in `run'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/initializable.rb:61:in `block in run_initializers'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/tsort.rb:228:in `block in tsort_each'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/tsort.rb:431:in `each_strongly_connected_component_from'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/initializable.rb:50:in `each'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/initializable.rb:50:in `tsort_each_child'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/tsort.rb:415:in `call'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/tsort.rb:415:in `each_strongly_connected_component_from'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/tsort.rb:349:in `block in each_strongly_connected_component'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/tsort.rb:347:in `each'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/tsort.rb:347:in `call'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/tsort.rb:347:in `each_strongly_connected_component'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/tsort.rb:226:in `tsort_each'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/tsort.rb:205:in `tsort_each'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/initializable.rb:60:in `run_initializers'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/application.rb:391:in `initialize!'
        from /home/tricia/Code/jupiter/config/environment.rb:5:in `<main>'
        from config.ru:3:in `require_relative'
        from config.ru:3:in `block in <main>'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/builder.rb:116:in `eval'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/builder.rb:116:in `new_from_string'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/builder.rb:105:in `load_file'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/builder.rb:66:in `parse_file'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/server.rb:349:in `build_app_and_options_from_config'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/server.rb:249:in `app'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/server.rb:422:in `wrapped_app'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/commands/server/server_command.rb:77:in `log_to_stdout'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/commands/server/server_command.rb:37:in `start'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/commands/server/server_command.rb:144:in `block in perform'
        from <internal:kernel>:90:in `tap'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/commands/server/server_command.rb:135:in `perform'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/command/base.rb:69:in `perform'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/command.rb:48:in `invoke'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/railties-6.1.7.6/lib/rails/commands.rb:18:in `<main>'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /home/tricia/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from bin/rails:4:in `<main>'

I'll take a closer look, but maybe you'll spot it faster.

@@ -107,10 +107,6 @@ group :development do

gem 'brakeman'

gem 'listen', '>= 3.0.5', '< 3.9'
Copy link
Member

@pgwillia pgwillia Sep 19, 2023

Choose a reason for hiding this comment

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

Seems like listen is still needed.

# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bootsnap gem has no dependency on Listen. Maybe it's a caching thing 🤔. Wonder if you blow away your tmp directory if that fixes it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Listen was in the gem in 6.1.7+ in Rails with Spring but was removed in 7.0 (so unless Rails needs it for some reason? But this was working for me)

Copy link
Member

Choose a reason for hiding this comment

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

It's the config.file_watcher = ActiveSupport::EventedFileUpdateChecker in the development environment.

Copy link
Contributor Author

@murny murny Sep 19, 2023

Choose a reason for hiding this comment

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

Ah, never mind I'm getting same error when I run the server (tests work fine surprisingly). Let's put listen back in, and we can remove listen in Rails 7. My assumption is Rails uses Listen for hot reload in development mode. Thanks for checking!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay Listen is back!

Copy link
Member

@pgwillia pgwillia left a comment

Choose a reason for hiding this comment

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

@murny murny merged commit 6278345 into master Sep 22, 2023
2 checks passed
@murny murny deleted the remove-spring-gem branch September 22, 2023 23:42
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