3

When I run a rails app and navigate with browser to them I get an error from rails:

Permission denied - /path/to/my_rails_app/tmp/cache/assets/development/sprockets/37b5a12047376b10a57191a10d3af30a rails error

And I have no such file/folders behind the ./tmp/. What is the problem?

Promise Preston
  • 24,334
  • 12
  • 145
  • 143
static
  • 8,126
  • 15
  • 63
  • 89

4 Answers4

7

I experienced this same issue.

Permission denied @ apply2files

The problem is that tmp directory in your application directory is not writable to the current user, that is, the current user does not have permission to write to the tmp directory in your application directory.

Here's how I solved it:

Simply delete the tmp directory in your application directory with superuser rights:

sudo rm -rf tmp

Do not recreate the tmp directory again, it's a waste of effort

Simply start your application and the tmp directory will be created automatically again:

rails s

That's all.

I hope this helps

Promise Preston
  • 24,334
  • 12
  • 145
  • 143
5

The user who created or 'owns" the my_rails_app directory isn't writable by the server.

chown -R webserveruser:webserveruser /path/to/my_rails_app

Change the webserveruser to http, or apache or whatever username is running your server. The entitiy to the right of the : is the group, use a group name that is writable by your user if you need write access without changing users.

trh
  • 7,186
  • 2
  • 29
  • 41
  • I tried to figure out which user runs my nginx with phusion passenger, so: `ps aux | grep nginx` -> `root` and `nobody`. I run the nginx via `sudo /opt/nginx/sbin/nginx` (installed with phusion passenger, no init.d script) – static Oct 14 '13 at 16:49
  • 3
    I solved the problem so: remove the tmp with `rm -rf .tmp` and recreate it again `mkdir tmp`, now no errors – static Oct 14 '13 at 16:52
  • awesome @static, you really made my made graceful. Exactly works on my system. – Sreekanth Jan 12 '15 at 07:59
  • In my case, I opened up my IDE as a root user upon first installation, and then running web app caused some things in `tmp/` to be owned by root. Taking ownership of everything in `tmp/` solved the issue for me. – Jack Feb 11 '16 at 21:16
2

The reason this error was happening for me was because I was running

ruby bin/rails server 

instead of

ruby bin/rails server -e development
Jeffrey Kozik
  • 201
  • 4
  • 8
0

try this:

rm -rf public/assets rake assets:clean RAILS_ENV=development

chown -R nginx:nginx /www/rblpt/

JAGJ jdfoxito
  • 747
  • 5
  • 5