问题
This seems like it would be a common problem, but I just can't seem to find the solution through google searches, etc.
I just created a new Rails 3.2.6 application and configured it to use the PostgreSQL database for my local development. I followed this RailsCast and was able to get everything installed and set up correctly.
However, whenever I try to do any rails generate or rake commands (rails generate model
, rake db:migrate
etc), I get the following error referring to my development.log
file:
Rails Error: Unable to access log file. Please ensure that /Users/****/projects/rails_projects/rails_app/log/development.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
I see these other stackoverflow questions/answers, but they don't fit my case exactly:
- Rails: Unable to access log file <- This is back in the days of Rails 2.2
- Ruby on Rails Setup: Unable to access log file <- This is regarding a production environment using Apache. I am on a local development environment.
Other than that error, my application runs fine. Also, if I create a new rails application with all its defaults, I don't get this error.
Any suggestions/hints would be much appreciated. Or if you need any more information about my local environment, please let me know.
回答1:
Have you verified that the log file is there and that you can access it? I've done some similar things in the past.
回答2:
I basically did what the error message suggested and did a chmod 0666
on the development.log
file:
$> cd /Users/****/projects/rails_projects/rails_app/log/
$> chmod 0666 development.log
Everything worked fine after that.
回答3:
Check it out with sudo
if your enviroment its on linux, for example, i got that error trying to run the migration - rake db:migrate
, so i used sudo rake db:migrate
and that's work, maybe because the rake when its trying to consult development.log doesn't have the right permissions or something like that.
来源:https://stackoverflow.com/questions/11516358/rails-3-2-6-getting-unable-to-access-log-file-error-for-development-log-file