简体   繁体   中英

Permission denied in tmp

I just deployed a Rails 3 app with Ruby 1.9.2. I have been getting several errors.

  1. application.css wasn't compiled. so I set pre compilation in production.rb to false;
  2. Then I got: cannot generate tempfile , so I did rake tmp:clear ;
  3. And now I get ActionView::Template::Error (Permission denied - /srv/www/appname/tmp/cache/assets): and I haven't been able to fix this one.

Please help.

If the user:group running your web server is http:http and it's running on *nix, do this:

sudo chown -R http:http /srv/www/appname/

Also, silly question, but does /tmp/cache/assets exist?

And, if so, as @leonel points out, you may also need to change the permissions:

chmod 777 /srv/www/appname/tmp/cache

Be careful setting 777 permissions on anything. Only do this to verify a permissions issue, then reset to the most minimal permissions necessary.

Most likely you're running your app under apache passenger.

You have to change the owner of config/environment.rb to somebody who has permissions to your app's folder.

chown -R www-data:www-data /path/to/app
  1. Make the tmp folder of your project writable:

     chown -R group:user /path/to/rails/app/tmp chmod -R 777 /path/to/rails/app/tmp 
  2. In your console, run rake tmp:cache:clear

  3. Restart your application.

You probably didn't create your Rails application with the user running the server now. Can you paste the output of ls -alh /srv/www/appname/tmp/cache/assets and tell us the user running the webserver ?

I encountered this error recently. Apache was not able to write to tmp directory

cannot generate tempfile /tmp/RackRewindableInput2xxxxxxxxxxxxxxxxx' /app-lib/lib/ruby/1.8/tempfile.rb:52:in initialize' app-dir/vendor/gems/rack-1.0.1/lib/rack/rewindable_input.rb:73:in new' app-dir/vendor/gems/rack-1.0.1/lib/rack/rewindable_input.rb:73:in make_rewindable' app-dir/vendor/gems/rack-1.0.1/lib/rack/rewindable_input.rb:26:in read' app-dir/vendor/gems/rack-1.0.1/lib/rack/request.rb:134:in POST'

I checked permission of tmp directory and it had permission to all groups to write to it. I changed owner of tmp directory and it didn't resolve the error either.

The culprit was tmp directory was filled with too many large files, and looks like somehow apache didn't had enough space to write this new file. Cleared all temp and old files. It sorted out the issue.

Now for those of us that are using windows - If you are an administrator and see this error

ActionView::Template::Error (Permission denied @ utime_failed) C:/User/..../tmp/cache/assets/sprochets/v3.0/E5/E5PZx-mq8.cache

Then it is Permission and Ownership setting issue on Windows. You can go to the tmp folder on your application and give yourself(User) permission to **Read, Write and Execute ** on the folder. Click [here][1] to view how to give permissions.

Quick Fix. Open your terminal and run the following command as an administrator

    takeown /f <location of your app tmp folder> /r /d y

Then Restart your server.

We need to grant permissions to access the required directory for the system root user

sudo chmod 777 -R your_project_directory_to_be_access

In your case you can use:

sudo chmod 777 -R /srv/www/appname/tmp/

For security reasons, just keep in your mind:

chmod 777 gives everybody read, write and execute rights which for most problems is definitively too much.

I think a better solution without giving everyone manage rights to tmp folder is like that:

 sudo rake tmp:cache:clear

This will clear the temp folder and when you run rails server again it won't give error.

在我的localhost中它给出了这个错误,命令chmod 777 C:/Sites/project_name/tmp/cache/解决了我的问题。

Most probably you gave permission to your app's main folder read and execute mode . However, in order to generate new files from your app, you also need to give write permission for required folder . For example: yUML uses tmp folder for generating files. I gave tmp folder write permission:

chmod -R 777 /usr/share/nginx/html/yuml_product/tmp

solved my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM