This project is archived and is in readonly mode.

#2379 new
Phil Hagelberg

[PATCH] Make path to tmp directory configurable

Reported by Phil Hagelberg | March 31st, 2009 @ 12:12 AM | in 3.0.6

To ease certain types of deployments, it's desirable that the tmp directory be configurable in the Initializer block rather than hardcoded in. This patch implements that option as well as making other parts of Rails respect the new option.

This (along with ticket #2350) makes it possible to deploy Rails apps as ruby gems, keeping all instance-specific data in a single directory while the application code lives in the gem home.

Comments and changes to this ticket

  • Jeff Hodges

    Jeff Hodges March 31st, 2009 @ 12:15 AM

    +1

    This is a solid patch. I would like the task description "Clears all session files in tmp" changed to desc "Clears all session files in the tmp directory" and similar to the other one. However, that's just being picky.

  • Phil Hagelberg

    Phil Hagelberg March 31st, 2009 @ 02:23 AM

    • Tag changed from configuration to configuration, patch
  • Xavier Noria

    Xavier Noria March 31st, 2009 @ 05:01 AM

    Two things I'd like to improve:

    • I think tmp_dir may be useful to the end user, what about documentation for it.

    • I think it is better style not to mix slashes and File.join. If you use File.join then leave slashes to it.

    • The analogous accessors for lots of stuff end with "_path". To be consistent in that naming I'd call it "tmp_path".

  • Phil Hagelberg

    Phil Hagelberg March 31st, 2009 @ 05:08 AM

    Thanks, fellas. I will make these changes and attach another patch.

    I added comments for the tmp_dir accessor; I believe those should get picked up by RDoc. Is there somewhere else it should be documented?

  • Phil Hagelberg
  • Shane Liebling

    Shane Liebling July 12th, 2009 @ 09:39 PM

    I was wondering if this was going to get rolled into the mainline rails anytime soon - I for one could really use it!!

  • CancelProfileIsBroken

    CancelProfileIsBroken August 7th, 2009 @ 02:28 PM

    • Tag changed from configuration, patch to bugmash, configuration, patch
  • Kieran P

    Kieran P August 8th, 2009 @ 07:05 AM

    +1, but the patch supplied does not apply cleanly to Rails 3.0 (master). I've uploaded a modified patch that does.

  • Kieran P

    Kieran P August 8th, 2009 @ 07:28 AM

    Previous file wasn't a proper patch. This one should be better.

  • Dan Pickett

    Dan Pickett August 8th, 2009 @ 11:52 PM

    +1 for the feature

    verified that the patch applies cleanly to master

    There currently isn't any tests associated with this patch - would it be possible to include tests on this? (I'm asking if its possible, not being patronizing :-) )

  • José Valim

    José Valim August 9th, 2009 @ 12:08 AM

    • Assigned user set to “Yehuda Katz (wycats)”
    • Milestone cleared.

    I was discussing about this feature with Yehuda a week ago. He told me that all Rails paths should be configurable, like Rails.paths.vendor #=> RAILS_ROOT/vendor. Not sure if he is already working on that with Carl, but I'm assigning it to him.

  • Rizwan Reza

    Rizwan Reza August 9th, 2009 @ 12:16 AM

    +1 I agree with Yehuda on all Rails path being configurable... that would be awesome!

  • Elad Meidar

    Elad Meidar August 9th, 2009 @ 05:25 AM

    +1 on idea and approach to have all paths as configurable.

    patch applies cleanly but contains a typo (fixed patch attached), i was unable to think of a proper way to test it, nor where other paths are tested.
    I also think that it should be somewhat a Configuration accessor, other than the Rails instance.

  • Kieran P

    Kieran P August 9th, 2009 @ 05:36 AM

    Michael (Koz) suggested (on IRC) that it be Rails.tmpdir to match Dir.tmpdir used other places in Rails, so I based the getter/setter from public_path, rather than make a Configuration accessor as in the original patch.

  • Yehuda Katz (wycats)

    Yehuda Katz (wycats) August 9th, 2009 @ 10:00 AM

    On master, we have already moved toward a more flexible way to describe paths. Check out this block from configuration.rb

          @paths = Rails::Application::Root.new(root_path)
          @paths.app                 "app",             :load_path => true
          @paths.app.metals          "app/metal",       :eager_load => true
          @paths.app.models          "app/models",      :eager_load => true
          @paths.app.controllers     "app/controllers", builtin_directories, :eager_load => true
          @paths.app.helpers         "app/helpers",     :eager_load => true
          @paths.app.services        "app/services",    :load_path => true
          @paths.lib                 "lib",             :load_path => true
          @paths.vendor              "vendor",          :load_path => true
          @paths.vendor.plugins      "vendor/plugins"
          @paths.tmp                 "tmp"
          @paths.tmp.cache           "tmp/cache"
          @paths.config              "config"
          @paths.config.locales      "config/locales"
          @paths.config.environments "config/environments", :glob => "#{RAILS_ENV}.rb"
    

    The basic idea is that we mirror the default directory structure for ease of understanding, but users can specify whatever paths they want for a part of the path hierarchy. Each virtual path can also have multiple physical paths. When Carl gets back from vacation we'll finish this up (we got detoured to work on the gem bundler) and write it up.

  • Yehuda Katz (wycats)

    Yehuda Katz (wycats) August 9th, 2009 @ 10:00 AM

    • Tag changed from bugmash, configuration, patch to configuration, patch
  • Jeremy Kemper

    Jeremy Kemper August 30th, 2010 @ 04:10 AM

    • Milestone cleared.
    • Importance changed from “” to “”
  • Jeremy Kemper

    Jeremy Kemper October 15th, 2010 @ 11:01 PM

    • Milestone set to 3.0.2
  • Santiago Pastorino
  • Santiago Pastorino
  • Santiago Pastorino

    Santiago Pastorino February 27th, 2011 @ 03:15 AM

    • Milestone changed from 3.0.5 to 3.0.6

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages