This project is archived and is in readonly mode.
Cache fragment file creation error : "Couldn't create cache directory: ** (Permission denied - .permissions_check.-**)"
Reported by brunetton | February 13th, 2009 @ 04:34 PM | in 2.x
Hi all,
In brief Under certain conditions, fragment cache file creation isn't done (while it's possible).
Error
Couldn't create cache directory: views/menu_onglets (Permission denied - .permissions_check.-605420708.8937.647701)
Cached fragment miss: views/menu_onglets (0.5ms)
Conditions This error comes when : * ActionController::Base.cache_store isn't default (set to RAILS_ROOT/tmp/cache for example, useful to clearly separate cache files when multiple Rails apps are hosted on the same server and to have an empty cache after each Capistrano deploy) * and RAILS_ROOT isn't writable by Rails process
Description (assuming there is no cache files at all) * ActiveSupport::Cache::write() calls File::atomic_write() (defined in activesupport/lib/active_support/core_ext/file/atomic.rb) with a temp_dir argument * atomic_write()
* successfully creates the temp cache file (*temp_file*) in *temp_dir* with the fragment
* tries to get original file stats (because it's the first write) and executes the *rescue* block. This is normal
Problem and solution The code in the rescue block is intended to determine the default cache dir permissions (old_stat) by creating a temporary empty file.
The problem is that the temp file used for permissions (check_name) isn't created in the cache dir, but in current dir (RAILS_ROOT) :
check_name = ".permissions_check.#{Thread.current.object_id}.#{Process.pid}.#{rand(1000000)}"`
To correct this :
check_name = join(dirname(file_name), ".permissions_check.#{Thread.current.object_id}.#{Process.pid}.#{rand(1000000)}")
(patch joined)
Additional infos Rails version : 2.2.2 (I suppose it's also the case in 2.2.3 branch) Server : Mongrel or Apache/modrails/ree
Comments and changes to this ticket
-
brunetton February 13th, 2009 @ 04:46 PM
Sorry for formatting problems in description
Again :
Description (assuming there is no cache files at all)
- ActiveSupport::Cache::write() calls File::atomic_write() (defined in activesupport/lib/active_support/core_ext/file/atomic.rb) with a temp_dir argument
- atomic_write()
- successfully creates the temp cache file (temp_file) in temp_dir with the fragment
- tries to get original file stats (because it's the first write) and executes the rescue block. This is normal
-
brunetton February 13th, 2009 @ 04:50 PM
the last two points were supposed to be indented. I tried first in Dingus (official Markdown sandbox)
-
Pratik February 18th, 2009 @ 03:53 PM
- Assigned user set to josh
-
Repository February 20th, 2009 @ 03:02 AM
- State changed from new to resolved
(from [3d15e1a7b5c996baf11728ed32945b0d27418b1a]) Make atomic_write() puts the check_file in the cache dir, not in application root [#1962 state:resolved] Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...
-
Repository February 20th, 2009 @ 03:02 AM
(from [3668a641702b6d0e5df963f54de8d17c53d6179c]) Make atomic_write() puts the check_file in the cache dir, not in application root [#1962 state:resolved] Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...
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>
People watching this ticket
Attachments
Tags
Referenced by
- 1962 Cache fragment file creation error : "Couldn't create cache directory: ** (Permission denied - .permissions_check.-**)" (from [3d15e1a7b5c996baf11728ed32945b0d27418b1a]) Make at...
- 1962 Cache fragment file creation error : "Couldn't create cache directory: ** (Permission denied - .permissions_check.-**)" (from [3668a641702b6d0e5df963f54de8d17c53d6179c]) Make at...