mirror of https://github.com/rails/rails
Use explicit spring boot loader (#39225)
This commit is contained in:
parent
58bed97226
commit
c6bdfd133f
|
@ -1,3 +1,8 @@
|
|||
* Use explicit `config/boot_with_spring.rb` boot file for bin/rails and bin/rake, which allows us to restrict Spring loading
|
||||
to only test and development, and everywhere to be able to skip spring by passing UNSPRUNG=1 as an env variable.
|
||||
|
||||
*DHH*
|
||||
|
||||
* The `classic` autoloader starts its deprecation cycle.
|
||||
|
||||
New Rails projects are strongly discouraged from using `classic`, and we recommend that existing projects running on `classic` switch to `zeitwerk` mode when upgrading. Please check the [_Upgrading Ruby on Rails_](https://guides.rubyonrails.org/upgrading_ruby_on_rails.html) guide for tips.
|
||||
|
|
|
@ -429,9 +429,9 @@ module Rails
|
|||
end
|
||||
end
|
||||
|
||||
def generate_spring_binstubs
|
||||
def generate_spring_binstub
|
||||
if bundle_install? && spring_install?
|
||||
bundle_command("exec spring binstub --all")
|
||||
bundle_command("exec spring binstub")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -347,6 +347,11 @@ module Rails
|
|||
template "config/boot.rb"
|
||||
end
|
||||
|
||||
def create_boot_with_spring_file
|
||||
return if options[:skip_spring]
|
||||
template "config/boot_with_spring.rb"
|
||||
end
|
||||
|
||||
def create_active_record_files
|
||||
return if options[:skip_active_record]
|
||||
build(:database_yml)
|
||||
|
@ -489,7 +494,7 @@ module Rails
|
|||
end
|
||||
|
||||
public_task :apply_rails_template, :run_bundle
|
||||
public_task :generate_bundler_binstub, :generate_spring_binstubs
|
||||
public_task :generate_bundler_binstub, :generate_spring_binstub
|
||||
public_task :run_webpack
|
||||
|
||||
def run_after_bundle_callbacks
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
APP_PATH = File.expand_path('../config/application', __dir__)
|
||||
<% if options.skip_spring? -%>
|
||||
require_relative "../config/boot"
|
||||
<% else -%>
|
||||
require_relative "../config/boot_with_spring"
|
||||
<% end -%>
|
||||
require "rails/commands"
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
<% if options.skip_spring? -%>
|
||||
require_relative "../config/boot"
|
||||
<% else -%>
|
||||
require_relative "../config/boot_with_spring"
|
||||
<% end -%>
|
||||
require "rake"
|
||||
Rake.application.run
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
if ENV["UNSPRUNG"].nil? && (ENV["RAILS_ENV"].nil? || ENV["RAILS_ENV"] == "development" || ENV["RAILS_ENV"] == "test")
|
||||
begin
|
||||
load File.expand_path("../../bin/spring", __FILE__)
|
||||
rescue LoadError => e
|
||||
raise unless e.message.include?("spring")
|
||||
end
|
||||
end
|
||||
|
||||
require_relative "boot"
|
|
@ -1066,7 +1066,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
|
|||
template
|
||||
end
|
||||
|
||||
sequence = ["git init", "install", "binstubs bundler", "exec spring binstub --all", "webpacker:install", "echo ran after_bundle"]
|
||||
sequence = ["git init", "install", "binstubs bundler", "exec spring binstub", "webpacker:install", "echo ran after_bundle"]
|
||||
@sequence_step ||= 0
|
||||
ensure_bundler_first = -> command, options = nil do
|
||||
assert_equal sequence[@sequence_step], command, "commands should be called in sequence #{sequence}"
|
||||
|
|
Loading…
Reference in New Issue