I am running into a permissions error only when I try to run my app on heroku. My app works perfectly on my local machine but when I push it to heroku, I get a write error in the logs:
2011-10-27T16:55:14+00:00 app[web.1]: Errno::EACCES (Permission denied - /app/public/stylesheets/active_admin.css):
I am not quite sure how to fix this since it works on my local machine. Why would this file need public write permissions?
EDIT: Why would activeadmin need write access to that file? How do I work around that?
Heroku has a read only file system. See http://devcenter.heroku.com/articles/read-only-filesystem
If you make a new app on cedar, you'd be able to write, but it won't stick around. See http://devcenter.heroku.com/articles/dyno-isolation#ephemeral_filesystem
If you continue to have problems, you should contact support http://suport.heroku.com
ActiveAdmin uses Sass and tries to compile it live, but Heroku disallows this.
To fix, I have this at the top of config/initializers/active_admin.rb (outside of the ActiveAdmin.setup block):
Sass::Plugin.options[:never_update] = true
Source: https://github.com/gregbell/active_admin/issues/44#issuecomment-1305038
Another workaround would simply be to save the active_admin.css file (when you're on your local machine) and simply upload it to your css folder.
I have the same problem and I found this initializer to fix the path for the CSS file.
https://gist.github.com/1012619
It's work perfect for me.
Related
I am using Heroku to try to deploy a personal Ruby on Rails project and everything was going great until today.
I am very very new to Ruby on Rails and Heroku so please bare that in mind. I am not sure what is causing my issue and therefore not sure what code or information is best to supply so please ask me what you think you need to know to help resolve the issue and I will provide it.
My Ruby on Rails app worked fine both locally and on Heroku until I followed the information here to try and serve static images from Amazons S3 bucket. Note I only went as far as the static assets section.
This appeared to stop my Ruby on Rails application from recognising changes in my code. So I would make a change to a HTML file in my editor but the server was serving up the older version of the HTML file, even restarting the server didn't fix this.
I have been searching the web for hours trying to figure out what has gone wrong.
I deleted everything under public assets and I ran the precompile command:
rake assets:precompile
And this seems to have improved things locally, when I edit a HTML file the changes are reflected on localhost. However when I push to Heroku and go to my application hosted on Heroku it still shows the older HTML file no matter how many changes I make and pushes I do to Heroku.
The HTML files that are not updating are located here:
app/assets/templates
I'm not sure what I may have changed that has caused the HTML files not to get updated on Heroku?? What should I look at and try? What other information would be useful in helping track down the issue?
The answer marked as correct in this StackOverflow question worked for me - Updated CSS Stylesheet not loaded following deployment to Heroku? - It looks like I accidently added assets precompiled file in my git repo somewhere along my development and that caused the issue.
I've been hounded by the above error whenever my rails project has to alter the filesystem. Be it carrierwave image uploads or creating a folder via
Dir.mkdir
Lately I'm getting this error because the gem I'm using wants to create a directory at /home/git/repositories and it can't because it hits this permission error.
I know this is a stupid idea, but in desperation I've set /home recursively to 7777 and, against all sense and reason, I'm still getting
Errno::EACCES at /users
Permission denied
I've been hounded by this error. I had the same thing with carrierwave, even when I set its directory recursively to 7777
Same thing with paperclip too.
I fixed carrierwave by deleting the directory and letting carrierwave create the directory structure itself when it saw the directories weren't there. It was the only way I could do it, after much hair-pulling and setting every directory on my machine to 7777! (did it in a VM because I know how silly that is :P)
Is this something to do with the application server? What user is running the application server? I thunk that may be the key because it fixed the error when the application server created the directories, rather than myself doing it manually. But I just run the server normally, under my own account... the same account that creates the directories and sets the permissions... What am I doing wrong to continually hit this error?
Can I run something along the lines of sudo rails s?
Also I can't let the system create the directories because then I get a 'directory not found error'. I know I'm on the right lines because upon using mkdir manually to create /home/git/repositories I started getting Permission denied errors instead.
You probably don't want the stickbit/setuser/setgroup bits. Maybe you want 0664 instead, which grants read/write to the owning user/group, and read to other users.
If it's trying to write in /users then the problem is probably that /users doesn't exist and your root / only permits root to create directories. You should probably verify which paths it's trying to write to; just slinging permissive modes around is a) probably not going to solve the problem, b) leaves you open to security issues, and c) is a really bad habit to get in to.
Running your rails app as root will work, but is a truly awful idea. Don't do it.
I'm using PDFKit to create pdfs of from a given url within a Resque job on Heroku Cedar. My code looks like:
kit = PDFKit.new(url)
pdf = kit.to_file("/tmp/#{SecureRandom.hex}.pdf")
I then upload the file using fog to S3 for permanent storage. This job usually works, but also fails maybe a third of the time with:
No such file or directory - /tmp/a05c165fc80878b75fd15c447695de71.pdf
Manually running through the code in console will produce the same error.
According to the Heroku docs, I should be able to write a temporary file anywhere in the app's directory on Cedar. I've tried creating the tmp directory first (in console) but that didn't seem to change anything. Neither did saving to "#{Rails.root}/tmp/#{SecureRandom.hex}.pdf".
Any ideas would be greatly appreciated.
UPDATE
The full error in console is:
Error: Failed loading page http://grist.org/living/you-look-great-in-green-clothing-industry-gets-a-makeover-maybe.html
(sometimes it will work just to ignore this error with --load-error-handling ignore)
Errno::ENOENT: No such file or directory - /tmp/55a1d418074736decfd4e123d8e2bba2.pdf
It seems that maybe this is an error coming from wkhtmltopdf, however, I'm not sure where to add this flag if I'm using wkhtmltopdf via PDFkit.
Looks like the solution, as the error I posted second suggested, was to ignore the load error. I did this with:
PDFKit.configure do |config|
config.default_options[:load_error_handling] = 'ignore'
end
I wasn't seeing this warning at first because Resque was only showing me the final error. Thanks #ctshryock, your question made me think a little more about exactly where this error was coming from.
I'm having a problem with deploying a Rails 3 app to a Passenger/Apache2/RVM server running Ubuntu 11.10.
I'm getting the error:
A source file that the application requires, is missing.
...
Error message: No such file to load -- Goal
Exception class: LoadError
Goal is one of my Rails Models.
I've seen a lot of people with a similar error message, but their issues seem to relate to missing bundles/gems - not model files! Their problems were resolved by ensuring permissions were set up correctly, so to that end I've got:
Apache running as www-data, as is Passenger. RVM is installed as www-data and I've chown'd the entire web app directory to www-data.
I've been wrestling with this for some time now and am really out of ideas - if anyone has any suggestions I'd be very grateful!
You might probably have the file structure of your Rails app wrong. Are you sure you have the "goal.rb" file within {your_app_root_url}/app/models/ ?
To me, if I am seeing the error when you view the app in browser, it seems like your rails app and passenger(with apache2) are working fine. The other possibility is you might be looking at wrong app folder which passenger is set up to.
It's hard to tell what's wrong. Please provide more details of how you set up your passenger with your rails app directory. Also it would help if you could show what's inside your app (app structure) and what's inside goal.rb model file.
Well I've solved it. Turned out that a work around for a problem with yaml encoded model archives (i.e. an explicit require of Goal) in a completely unrelated Model was causing the error to appear. Looks like it only rears its head in production - probably due to the differences between the class loaders used in development vs. production.
Tough one to find... the stack trace didn't include a reference to where the problem actually was!
Hey all. I've got a new app up and running on a new ubuntu server. It's working fine generally but i can't get ar_sendmail working. I'm following the instructions on this page:
http://www.ameravant.com/posts/sending-tons-of-emails-in-ruby-on-rails-with-ar_mailer
The setup is all done, ie i can "deliver mails" which just saves records in my Email table. Now i want to get the ar_sendmail daemon running to actually send them. (so i'm at 'Running ar_sendmail in daemon mode' in that web page).
First thing:
ar_sendmail --mailq
>>ar_sendmail: command not found
Ok...so, where is ar_sendmail? I have a look and there's an ar_sendmail file in the bin folder of the ar_mailer plugin, so i add the location of that to my path. I don't know if this was the right thing to do or not.
Ok, so try again.
ar_sendmail --mailq
/var/www/apps/millionaire/vendor/plugins/ar_mailer/bin/ar_sendmail:3:in `require': no such file to load -- action_mailer/ar_sendmail (LoadError)
from /var/www/apps/millionaire/vendor/plugins/ar_mailer/bin/ar_sendmail:3
hmm. Here's the offending file, there's not much there.
#!/usr/bin/env ruby
require 'action_mailer/ar_sendmail'
ActionMailer::ARSendmail.run
ok...so it literally is just trying to require this and can't find it. The file, action_mailer/ar_sendmail.rb is in the ar_mailer plugin, in it's lib folder. So, given that it's being called from inside the plugin, it should be able to see this right?
I've got a feeling that i'm way off the track here and have missed something simple. Can anyone set me straight? I'm using rails 2.3.4 in case that's relevant.
EDIT - i just realised something kind of dumb: when i call ar_sendmail from the command line like this, i'm just loading that one file, which doesn't know where it's supposed to look for the rest of the stuff, i think. Which really makes me think that i'm not trying to run the right thing. Is the ar_sendmail daemon a seperate program altogether, that i would get with apt_get or something?
EDIT2 - i made some progress by installing the ar_mailer gem (which the guide said i shouldn't do) and that does seem to run. It's sending some mail request somewhere and clearing the Email table of pending emails. Running ar_sendmail in -ov (oneshot verbal) mode i see it report this for example:
sent email 00000000019 from from#address.com to to#address.com: #
So, it actually looks like it's working now and i just need to set up the ACTUAL THING WHICH SENDS EMAILS. sigh. still grateful for any advice.
thanks, max
What you need is an smtp server. Checkout www.sendgrid.com.