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 server command should use settings in config.paths #39583

Closed
MTres19 opened this issue Jun 10, 2020 · 2 comments
Closed

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

MTres19 opened this issue Jun 10, 2020 · 2 comments
Labels

Comments

@MTres19
Copy link

MTres19 commented Jun 10, 2020

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.

@rails-bot
Copy link

rails-bot bot commented Sep 8, 2020

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 6-0-stable branch or on master, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.

@rails-bot rails-bot bot added the stale label Sep 8, 2020
@rails-bot rails-bot bot closed this as completed Sep 15, 2020
@tcdowney
Copy link

As another datapoint, we're currently running into this issue when using the Paketo Ruby Cloud Native Buildpack to build and run certain Rails applications. For security reasons the buildpack does not allow its "run user" to write to application files so this call by Rails ends up failing:

2023-07-20T21:52:22.58-0600 [APP/] OUT /layers/paketo-buildpacks_mri/mri/lib/ruby/3.2.0/fileutils.rb:406:in `mkdir': Permission denied @ dir_s_mkdir - /workspace/tmp/pids (Errno::EACCES)

<truncated>

2023-07-20T21:52:22.58-0600 [APP/] OUT 	from /layers/paketo-buildpacks_bundle-install/launch-gems/ruby/3.2.0/gems/railties-7.0.4.3/lib/rails/commands/server/server_command.rb:71:in `block in create_tmp_directories'

<truncated>

It would be really useful if we could specify an alternative location for these temp directories since there are other writeable paths available to us.

paketo-buildpacks/ruby#889

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants