Skip to content

rails server command should use settings in config.paths #39583

@MTres19

Description

@MTres19

Expected behavior

To allow more flexible configuration, Rails allows configuring paths for certain purposes via Rails::Application::Configuration.paths. For example, in my config/environments/production.rb I can write:

config.paths['cache'] = ['/run/my-rails-app/tmp/cache']

This is good because /run on most Linux distributions is mounted using the tmpfs filesystem, which is much faster than a hard drive or even an SSD. The rails server command should obey the settings defined here.

Actual behavior

In railties/lib/rails/commands/server/server_command.rb, the paths for temporary files, cache, and sockets are hardcoded. This occurs in the function create_tmp_directories. Instead of using Rails.root.join, the server command should use Rails::Application.config.paths[dir_to_make].first

Note, however, that this will require defaults to be set for the sockets and cache paths in railties/lib/rails/application/configuration.rb

Is this a breaking change?

I do not think this should break much/anything. The paths configuration do not seem very well advertised and most likely are not used very much. The default path settings come out the same as what is already in use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions