Errno::EACCES: Permission denied @ utime_internal

Hey there,

When I have any ruby code in the app that needs to access /tmp/cache I receive this error:

Errno::EACCES: Permission denied @ utime_internal - /var/deploy/my-rails-app/web_head/releases/20150517045026/tmp/cache/assets/production/sprockets/v3.0/0BWrnGNZH6ufv6Xxn14IgywFXU8dLMU7-zr9-Snxwcg.cache
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/cache/file_store.rb:68:in `get'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/cache.rb:206:in `get'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/cache.rb:83:in `fetch'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/base.rb:53:in `file_digest'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/loader.rb:147:in `fetch_asset_from_dependency_cache'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/loader.rb:38:in `load'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/cached_environment.rb:47:in `yield'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/cached_environment.rb:47:in `load'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/base.rb:63:in `find_asset'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/base.rb:70:in `find_all_linked_assets'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/manifest.rb:130:in `block in find'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/manifest.rb:129:in `each'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/manifest.rb:129:in `find'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/sprockets/manifest.rb:162:in `compile'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-3.0.3/lib/rake/sprocketstask.rb:147:in `with_logger'
/var/deploy/my-rails-app/web_head/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'

I believe this issue is caused because only a certain user can access the tmp and I’m not that user. I have this in my manifest.yml file:

production:
  after_symlink:
    - command: cd $STACK_PATH && mkdir -p tmp/uploads && chmod 777 -R tmp/
      target: rails
      apply_during: all
      run_on: all_servers

But it doesn’t work. I can tell because the tmp/uploads folder is never made and the error is still present.

I need access to the tmp folder to send emails, run assets:precompile, and debug.

Hi Ben,

I believe you’ve placed that deploy hook in the wrong file - it belongs in a file called deploy_hooks.yml (in your .cloud66 folder).

Also, your deploy hook is setting permissions on the $STACK_PATH/tmp/uploads folder, not the $STACK_PATH/tmp/cache folder your code seems to be using. Please have a look at this deploy hook with a sticky bit as well, as this will ensure new files created in that folder will retain your set permission.

Philip

Trying with this:

production:
  after_symlink:
    - command: cd $STACK_PATH && mkdir -p tmp/cache && chmod 777 -R tmp/
      target: rails
      apply_during: all
      run_on: all_servers

    - command: cd $STACK_PATH && chown nginx:app_writers tmp && chmod 775 tmp && sudo chmod g+s tmp
      target: rails
      run_on: all_servers
      sudo: true

When I run cd $STACK_PATH && bundle exec rake assets:precompile I still get the same error.

Have you deleted the Git branch this stack was based on? I was going to check but it’s not possible to deploy your stack. I’d suggest that you email us on support (referencing this question) so that we can help you better.

You must be logged in to answer this question