From 77d113d640730bedca16814c7cc62a4eb776a2c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 15 Apr 2024 00:50:30 +0200 Subject: [PATCH] Don't add autoload_paths to load_path Quoting the Rails configuration guide [1]: > applications running in :zeitwerk mode do not need require_dependency, > so models, controllers, jobs, etc. do not need to be in $LOAD_PATH. > Setting this to false saves Ruby from checking these directories when > resolving require calls with relative paths, and saves Bootsnap work > and RAM, since it does not need to build an index for them. [1] https://guides.rubyonrails.org/v7.1/configuring.html#config-add-autoload-paths-to-load-path --- config/application.rb | 7 +++++++ config/initializers/new_framework_defaults_7_1.rb | 10 ---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/config/application.rb b/config/application.rb index 055ff57ff..ff3b866bc 100644 --- a/config/application.rb +++ b/config/application.rb @@ -31,6 +31,13 @@ module Consul config.load_defaults 7.0 + # No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able + # to manually require files that are managed by the autoloader, which you shouldn't do anyway. + # + # This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size + # of the bootsnap cache if you use it. + config.add_autoload_paths_to_load_path = false + # Keep belongs_to fields optional by default, because that's the way # Rails 4 models worked config.active_record.belongs_to_required_by_default = false diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb index 4ba02970b..9771bd6a8 100644 --- a/config/initializers/new_framework_defaults_7_1.rb +++ b/config/initializers/new_framework_defaults_7_1.rb @@ -9,16 +9,6 @@ # Read the Guide for Upgrading Ruby on Rails for more info on each option. # https://guides.rubyonrails.org/upgrading_ruby_on_rails.html -### -# No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able -# to manually require files that are managed by the autoloader, which you shouldn't do anyway. -# -# This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size -# of the bootsnap cache if you use it. -# -# To set this configuration, add the following line to `config/application.rb` (NOT this file): -# config.add_autoload_paths_to_load_path = false - ### # Remove the default X-Download-Options headers since it is used only by Internet Explorer. # If you need to support Internet Explorer, add back `"X-Download-Options" => "noopen"`.