Permission denied on deploying Rails

October 27, 2014 12.4k views

Hi, I have successful deployed my Rails app on Ubuntu 14 but as I used active_admin gem so I got the below error with the stylesheet:

I, [2014-10-27T10:25:29.983751 #4242]  INFO -- :   Rendered vendor/bundle/ruby/2.1.0/bundler/gems/activeadmin-0173d95712a8/app/views/active_admin/devise/shared/_links.erb (2.0ms)
I, [2014-10-27T10:25:29.984013 #4242]  INFO -- :   Rendered vendor/bundle/ruby/2.1.0/bundler/gems/activeadmin-0173d95712a8/app/views/active_admin/devise/sessions/new.html.erb within layouts/active_admin_logged_out (167.9ms)
I, [2014-10-27T10:25:31.032396 #4242]  INFO -- : Completed 500 Internal Server Error in 1250ms
F, [2014-10-27T10:25:31.140842 #4242] FATAL -- : 
ActionView::Template::Error (Permission denied @ rb_sysopen - /home/rails/tmp/cache/assets/production/sprockets/2902b7df0c9e35fa9198cceb3b3001c3):
     6:   <title><%= [@page_title, render_or_call_method_or_proc_on(self, ActiveAdmin.application.site_title)].compact.join(" | ") %></title>
     8:   <% ActiveAdmin.application.stylesheets.each do |style, options| %>
     9:     <%= stylesheet_link_tag style, options %>
    10:   <% end %>
    11:   <% ActiveAdmin.application.javascripts.each do |path| %>
    12:     <%= javascript_include_tag path %>

Not sure what permission should I have here? Could you please assist me with this?

3 Answers

A fix that worked for me was to clear the cache

rake tmp:cache:clear

Your app server can't write the tmp directory of your application.

One solution would be making the group of the tmp folder the user that is running the app server and giving write permission to the group.

# Replace server with the name of the user running the app server.
chgrp -R server /home/rails/tmp
chmod -R g+w /home/rails/tmp

@kingsleychi: Cheers, mate. That actually worked. Sorry for my super late response. All good now ;-)

Have another answer? Share your knowledge.